This commit is contained in:
ManeraKai 2024-08-02 16:27:54 +03:00
parent 15db7737e7
commit a9ecaf4ac0
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
8 changed files with 276 additions and 222 deletions

View File

@ -10,7 +10,7 @@
"start": "web-ext run", "start": "web-ext run",
"nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox",
"start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox", "start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox",
"android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ", "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.firefox --adb-remove-old-artifacts",
"build": "web-ext build", "build": "web-ext build",
"test": "web-ext lint", "test": "web-ext lint",
"html": "rollup -c --config-popup && rollup -c --config-options" "html": "rollup -c --config-popup && rollup -c --config-options"

View File

@ -91,7 +91,9 @@ browser.tabs.onRemoved.addListener(tabId => {
} }
}) })
browser.commands.onCommand.addListener(async command => { browser.runtime.getPlatformInfo(r => {
if (r.os != "fuchsia" && r.os != "ios" && r.os != "android") {
browser.commands.onCommand.addListener(async command => {
browser.tabs.query({ active: true, currentWindow: true }, async tabs => { browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
const url = new URL(tabs[0].url) const url = new URL(tabs[0].url)
switch (command) { switch (command) {
@ -131,33 +133,41 @@ browser.commands.onCommand.addListener(async command => {
break break
} }
}) })
}) })
browser.contextMenus.create({ browser.contextMenus.create({
id: "settingsTab", id: "settingsTab",
title: browser.i18n.getMessage("settings"), title: browser.i18n.getMessage("settings"),
contexts: ["browser_action"], contexts: ["browser_action"],
}) })
browser.contextMenus.create({ browser.contextMenus.create({
id: "switchInstanceTab", id: "switchInstanceTab",
title: browser.i18n.getMessage("switchInstance"), title: browser.i18n.getMessage("switchInstance"),
contexts: ["browser_action"], contexts: ["browser_action"],
}) })
browser.contextMenus.create({ id: "copyReverseTab", title: "Copy Original", contexts: ["browser_action"] }) browser.contextMenus.create({ id: "copyReverseTab", title: "Copy Original", contexts: ["browser_action"] })
browser.contextMenus.create({ id: "redirectTab", title: "Redirect", contexts: ["browser_action"] }) browser.contextMenus.create({ id: "redirectTab", title: "Redirect", contexts: ["browser_action"] })
browser.contextMenus.create({ id: "reverseTab", title: "Redirect To Original", contexts: ["browser_action"] }) browser.contextMenus.create({ id: "reverseTab", title: "Redirect To Original", contexts: ["browser_action"] })
browser.contextMenus.create({ id: "redirectLink", title: "Redirect", contexts: ["link"] }) browser.contextMenus.create({ id: "redirectLink", title: "Redirect", contexts: ["link"] })
browser.contextMenus.create({ id: "redirectLinkInNewTab", title: "Redirect In New Tab", contexts: ["link"] }) browser.contextMenus.create({ id: "redirectLinkInNewTab", title: "Redirect In New Tab", contexts: ["link"] })
browser.contextMenus.create({ id: "reverseLink", title: "Redirect To Original", contexts: ["link"] }) 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({
browser.contextMenus.create({ id: "copyReverseLink", title: "Copy Original", contexts: ["link"] }) id: "reverseLinkInNewTab",
browser.contextMenus.create({ id: "bypassLink", title: "Bypass", contexts: ["link"] }) title: "Redirect To Original In New Tab",
browser.contextMenus.create({ id: "bypassLinkInNewTab", title: "Bypass In New Tab", contexts: ["link"] }) 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) { if (!isChrome) {
browser.contextMenus.create({ id: "redirectBookmark", title: "Redirect", contexts: ["bookmark"] }) browser.contextMenus.create({ id: "redirectBookmark", title: "Redirect", contexts: ["bookmark"] })
browser.contextMenus.create({ id: "redirectBookmarkInNewTab", title: "Redirect In New Tab", contexts: ["bookmark"] }) browser.contextMenus.create({
id: "redirectBookmarkInNewTab",
title: "Redirect In New Tab",
contexts: ["bookmark"],
})
browser.contextMenus.create({ id: "reverseBookmark", title: "Redirect To Original", contexts: ["bookmark"] }) browser.contextMenus.create({ id: "reverseBookmark", title: "Redirect To Original", contexts: ["bookmark"] })
browser.contextMenus.create({ browser.contextMenus.create({
id: "reverseBookmarkInNewTab", id: "reverseBookmarkInNewTab",
@ -167,9 +177,9 @@ if (!isChrome) {
browser.contextMenus.create({ id: "copyReverseBookmark", title: "Copy Original", 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: "bypassBookmark", title: "Bypass", contexts: ["bookmark"] })
browser.contextMenus.create({ id: "bypassBookmarkInNewTab", title: "Bypass In New Tab", contexts: ["bookmark"] }) browser.contextMenus.create({ id: "bypassBookmarkInNewTab", title: "Bypass In New Tab", contexts: ["bookmark"] })
} }
browser.contextMenus.onClicked.addListener(async info => { browser.contextMenus.onClicked.addListener(async info => {
switch (info.menuItemId) { switch (info.menuItemId) {
case "switchInstanceTab": { case "switchInstanceTab": {
const url = new URL(info.pageUrl) const url = new URL(info.pageUrl)
@ -307,6 +317,8 @@ browser.contextMenus.onClicked.addListener(async info => {
return return
}) })
} }
})
}
}) })
browser.runtime.onMessage.addListener((request, sender, sendResponse) => { browser.runtime.onMessage.addListener((request, sender, sendResponse) => {

View File

@ -1,7 +1,6 @@
<script> <script>
export let checked export let checked
export let onChange export let onChange
console.log(document.body.dir)
</script> </script>
<input class={document.body.dir} {...$$restProps} bind:checked on:change={onChange} type="checkbox" /> <input class={document.body.dir} {...$$restProps} bind:checked on:change={onChange} type="checkbox" />

View File

@ -14,14 +14,31 @@
const unsubscribe = options.subscribe(val => (_options = val)) const unsubscribe = options.subscribe(val => (_options = val))
onDestroy(unsubscribe) onDestroy(unsubscribe)
let bookmarksPermission let disableBookmarks = null
browser.runtime.getPlatformInfo(r => {
switch (r.os) {
case "fuchsia":
case "ios":
case "android":
disableBookmarks = true
break
default:
disableBookmarks = false
}
if (!disableBookmarks) {
browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
$: if (bookmarksPermission) { }
})
let bookmarksPermission
$: if (disableBookmarks !== null && disableBookmarks === false) {
if (bookmarksPermission) {
browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
} else { } else {
browser.permissions.remove({ permissions: ["bookmarks"] }) browser.permissions.remove({ permissions: ["bookmarks"] })
bookmarksPermission = false bookmarksPermission = false
} }
}
</script> </script>
<div> <div>
@ -68,10 +85,12 @@
/> />
</Row> </Row>
{#if disableBookmarks === false}
<Row> <Row>
<Label>{browser.i18n.getMessage("bookmarksMenu") || "Bookmarks menu"}</Label> <Label>{browser.i18n.getMessage("bookmarksMenu") || "Bookmarks menu"}</Label>
<Checkbox bind:checked={bookmarksPermission} /> <Checkbox bind:checked={bookmarksPermission} />
</Row> </Row>
{/if}
<Exceptions /> <Exceptions />

View File

@ -59,7 +59,6 @@
async function pingInstances() { async function pingInstances() {
pingCache = {} pingCache = {}
for (const instance of allInstances) { for (const instance of allInstances) {
console.log("pinging...", instance)
pingCache[instance] = { color: "lightblue", value: "pinging..." } pingCache[instance] = { color: "lightblue", value: "pinging..." }
const time = await utils.ping(instance) const time = await utils.ping(instance)
pingCache[instance] = colorTime(time) pingCache[instance] = colorTime(time)

View File

@ -32,8 +32,9 @@
<div> <div>
<Row> <Row>
<Label> <Label>
Service: <a href={serviceConf.url} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
<a href={serviceConf.url} target="_blank" rel="noopener noreferrer">{serviceConf.url}</a> {browser.i18n.getMessage("service") || "Service"}
</a>
</Label> </Label>
<div dir="ltr"> <div dir="ltr">
<SvelteSelect <SvelteSelect
@ -91,9 +92,8 @@
<Row> <Row>
<Label> <Label>
{browser.i18n.getMessage("frontend") || "Frontend"}: <a href={frontendWebsite} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
<a href={frontendWebsite} target="_blank" rel="noopener noreferrer"> {browser.i18n.getMessage("frontend") || "Frontend"}
{frontendWebsite}
</a> </a>
</Label> </Label>
<div dir="ltr"> <div dir="ltr">

View File

@ -41,7 +41,14 @@
<div class={document.body.dir}> <div class={document.body.dir}>
{#if redirect} {#if redirect}
<Row class="interactive" on:click={() => browser.runtime.sendMessage("redirectTab")}> <Row
class="interactive"
on:click={() => {
browser.runtime.sendMessage("redirectTab", () => {
window.close()
})
}}
>
<Label>{browser.i18n.getMessage("redirect") || "Redirect"}</Label> <Label>{browser.i18n.getMessage("redirect") || "Redirect"}</Label>
<RedirectIcon /> <RedirectIcon />
</Row> </Row>
@ -50,7 +57,10 @@
{#if switchInstance} {#if switchInstance}
<Row <Row
class="interactive" class="interactive"
on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} on:click={async () =>
browser.tabs.update({ url: await servicesHelper.switchInstance(url) }, () => {
window.close()
})}
> >
<Label>{browser.i18n.getMessage("switchInstance") || "Switch Instance"}</Label> <Label>{browser.i18n.getMessage("switchInstance") || "Switch Instance"}</Label>
<SwitchInstanceIcon /> <SwitchInstanceIcon />
@ -62,7 +72,13 @@
<Label>{browser.i18n.getMessage("copyOriginal") || "Copy Original"}</Label> <Label>{browser.i18n.getMessage("copyOriginal") || "Copy Original"}</Label>
<CopyIcon /> <CopyIcon />
</Row> </Row>
<Row class="interactive" on:click={() => browser.runtime.sendMessage("reverseTab")}> <Row
class="interactive"
on:click={() =>
browser.runtime.sendMessage("reverseTab", () => {
window.close()
})}
>
<Label>{browser.i18n.getMessage("redirectToOriginal" || "Redirect to Original")}</Label> <Label>{browser.i18n.getMessage("redirectToOriginal" || "Redirect to Original")}</Label>
<RedirectToOriginalIcon /> <RedirectToOriginalIcon />
</Row> </Row>
@ -85,7 +101,13 @@
<hr /> <hr />
<Row class="interactive" on:click={() => window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> <Row
class="interactive"
on:click={() =>
browser.tabs.create({ url: browser.runtime.getURL("pages/options/index.html") }, () => {
window.close()
})}
>
<Label>{browser.i18n.getMessage("settings")}</Label> <Label>{browser.i18n.getMessage("settings")}</Label>
<SettingsIcon /> <SettingsIcon />
</Row> </Row>

View File

@ -28,7 +28,10 @@
<div <div
class="interactive" class="interactive"
on:keydown={null} on:keydown={null}
on:click={() => window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")} on:click={() =>
browser.tabs.create({ url: browser.runtime.getURL(_config.services[serviceKey].url) }, () => {
window.close()
})}
> >
<ServiceIcon details={{ value: serviceKey, label: _config.services[serviceKey].name }} /> <ServiceIcon details={{ value: serviceKey, label: _config.services[serviceKey].name }} />
<Label>{_config.services[serviceKey].name}</Label> <Label>{_config.services[serviceKey].name}</Label>