Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
}
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);
}
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})
}
}
};
return Promise.all(filter(cs, 'history').map(({ args }) => browser.history.deleteUrl({ url: args[0] })));
}
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,
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)`,
}));
}