How to use the webextension-polyfill.history function in webextension-polyfill

To help you get started, we’ve selected a few webextension-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cnwangjie / better-onetab / src / common / tabs.js View on Github external
if (tabs.length === 0) return
  const lists = await storage.getLists()
  if (listIndex == null) {
    const newList = createNewTabList({tabs})
    if (opts.pinNewList) newList.pinned = true
    await listManager.addList(newList)
  } else {
    const list = lists[listIndex]
    tabs.forEach(tab => list.tabs.push(tab))
    await listManager.updateListById(list._id, _.pick(list, 'tabs'))
  }
  if (opts.addHistory) {
    for (let i = 0; i < tabs.length; i += 1) {
      // maybe occur Error: "An unexpected error occurred" when trying to add about:* to history
      try {
        await browser.history.addUrl({url: tabs[i].url})
      } catch (e) {
        console.debug(`${tabs[i].url} cannot be added to history`)
      }
    }
  }
  return browser.tabs.remove(tabs.map(i => i.id))
}
github GabLeRoux / webextensions-history-browser / src / js / history.js View on Github external
function load_history(callback, query) {
    // Get all of the history
    if (typeof query === 'undefined') {
        query = {
            text: "",
            startTime: 0,
            // endTime: new Date(), // This fails on chrome for some reason
            maxResults: maxResult // todo: setting
        };
    }
    // https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/history/search
    browser.history.search(query).then(callback);
}
github rejerry / bookmark / src / common / onetab / tabs.js View on Github external
if (nodes.length === 0) {
      console.log('请保持一个名字为"' + unSortFolder + '"的文件夹; 随后会为你自动创建一个"' + unSortFolder + '"文件夹');
      chrome.bookmarks.create({parentId: "2", title: unSortFolder}, (BookmarkTreeNode) => {
        createFolder(BookmarkTreeNode.id, newList);
      });
    } else if (nodes.length === 1) {
      createFolder(nodes[0].id, newList);
    } else {
      console.log('请保持一个名字为"' + unSortFolder + '"的文件夹; 存在多个"' + unSortFolder + '"文件夹,新创建的文件夹将会保存到最早创建的"' + unSortFolder + '"文件夹中;');
      createFolder(nodes[0].id, newList);
    }
  });

  if (opts.addHistory) {
    for (let i = 0; i < tabs.length; i += 1) {
      await browser.history.addUrl({url: tabs[i].url})
    }
  }
};
github kumabook / bebop / src / actions.js View on Github external
  return Promise.all(filter(cs, 'history').map(({ args }) => browser.history.deleteUrl({ url: args[0] })));
}
github lusakasa / saka / src / suggestion_engine / server / providers / history.js View on Github external
export async function allHistorySuggestions(searchText) {
  const results = await browser.history.search({
    text: searchText
  });

  const filteredResults = [];

  for (const result of results) {
    const sakaUrl = await isSakaUrl(result.url);
    !sakaUrl ? filteredResults.push(result) : null;
  }

  return filteredResults.map(
    ({ url, title, lastVisitTime, visitCount, typedCount }) => ({
      type: 'history',
      score: visitCount + typedCount,
      lastAccessed: lastVisitTime * 0.001,
      title,
github kumabook / bebop / src / sources / history.js View on Github external
export default function candidates(q, { maxResults } = {}) {
  const startTime = 0;
  return browser.history.search({ text: q, startTime, maxResults })
    .then(l => l.map(v => ({
      id:         `${v.id}`,
      label:      `${v.title}:${v.url}`,
      type:       'history',
      args:       [v.url],
      faviconUrl: getFaviconUrl(v.url),
    }))).then(items => ({
      items,
      label: `${getMessage('histories')} (:history or h)`,
    }));
}