This commit is contained in:
ManeraKai 2023-10-21 22:34:48 +03:00
parent 8649bad9b9
commit fb9acd1539
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
2 changed files with 38 additions and 2 deletions

View File

@ -142,6 +142,8 @@ browser.contextMenus.create({ id: "redirectLinkInNewTab", title: 'Redirect In Ne
browser.contextMenus.create({ id: "reverseLink", title: 'Redirect To Original', contexts: ["link"] })
browser.contextMenus.create({ id: "reverseLinkInNewTab", title: 'Redirect To Original In New Tab', contexts: ["link"] })
browser.contextMenus.create({ id: "copyReverseLink", title: 'Copy Original', contexts: ["link"] })
browser.contextMenus.create({ id: "bypassLink", title: 'Bypass', contexts: ["link"] })
browser.contextMenus.create({ id: "bypassLinkInNewTab", title: 'Bypass In New Tab', contexts: ["link"] })
if (!isChrome) {
browser.contextMenus.create({ id: "redirectBookmark", title: 'Redirect', contexts: ["bookmark"] })
@ -149,9 +151,10 @@ if (!isChrome) {
browser.contextMenus.create({ id: "reverseBookmark", title: 'Redirect To Original', contexts: ["bookmark"] })
browser.contextMenus.create({ id: "reverseBookmarkInNewTab", title: 'Redirect To Original In New Tab', contexts: ["bookmark"] })
browser.contextMenus.create({ id: "copyReverseBookmark", title: 'Copy Original', contexts: ["bookmark"] })
browser.contextMenus.create({ id: "bypassBookmark", title: 'Bypass', contexts: ["bookmark"] })
browser.contextMenus.create({ id: "bypassBookmarkInNewTab", title: 'Bypass In New Tab', contexts: ["bookmark"] })
}
browser.contextMenus.onClicked.addListener(async (info) => {
switch (info.menuItemId) {
case 'switchInstanceTab': {
@ -237,6 +240,21 @@ browser.contextMenus.onClicked.addListener(async (info) => {
return
}
case 'bypassLink':
case 'bypassLinkInNewTab': {
const url = new URL(info.linkUrl)
if (info.menuItemId == "bypassLink") {
browser.tabs.update({ url: url.href }, tab => {
tabIdRedirects[tab.id] = false
})
} else {
browser.tabs.create({ url: url.href }, tab => {
tabIdRedirects[tab.id] = false
})
}
return
}
case 'copyReverseBookmark': {
browser.bookmarks.get(info.bookmarkId, bookmarks => {
const url = new URL(bookmarks[0].url)
@ -244,6 +262,7 @@ browser.contextMenus.onClicked.addListener(async (info) => {
});
return
}
case 'redirectBookmark':
case 'redirectBookmarkInNewTab': {
browser.bookmarks.get(info.bookmarkId, bookmarks => {
@ -275,6 +294,23 @@ browser.contextMenus.onClicked.addListener(async (info) => {
})
return
}
case 'bypassBookmark':
case 'bypassBookmarkInNewTab': {
browser.bookmarks.get(info.bookmarkId, async bookmarks => {
const url = new URL(bookmarks[0].url)
if (info.menuItemId == "bypassBookmark") {
browser.tabs.update({ url: url.href }, tab => {
tabIdRedirects[tab.id] = false
})
} else {
browser.tabs.create({ url: url.href }, tab => {
tabIdRedirects[tab.id] = false
})
}
return
})
}
}
})

View File

@ -347,7 +347,7 @@ async function ping(frontend) {
element.appendChild(span)
const href = element.getElementsByTagName('a')[0].href
const innerHTML = element.getElementsByTagName('a')[0].innerHTML
const time = redundancyList[innerHTML] ?? await utils.ping(href)
const time = redundancyList[innerHTML] ?? await utils.ping(href)
const { color, text } = processTime(time)
span.innerHTML = `<span style="color:${color};">${text}</span>`
pingCache[innerHTML] = time