Improved mobile support. Fixed https://github.com/libredirect/browser_extension/issues/956
This commit is contained in:
parent
15db7737e7
commit
a9ecaf4ac0
|
@ -10,7 +10,7 @@
|
|||
"start": "web-ext run",
|
||||
"nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/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",
|
||||
"test": "web-ext lint",
|
||||
"html": "rollup -c --config-popup && rollup -c --config-options"
|
||||
|
|
|
@ -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 => {
|
||||
const url = new URL(tabs[0].url)
|
||||
switch (command) {
|
||||
|
@ -131,33 +133,41 @@ browser.commands.onCommand.addListener(async command => {
|
|||
break
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
browser.contextMenus.create({
|
||||
browser.contextMenus.create({
|
||||
id: "settingsTab",
|
||||
title: browser.i18n.getMessage("settings"),
|
||||
contexts: ["browser_action"],
|
||||
})
|
||||
browser.contextMenus.create({
|
||||
})
|
||||
browser.contextMenus.create({
|
||||
id: "switchInstanceTab",
|
||||
title: browser.i18n.getMessage("switchInstance"),
|
||||
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: "reverseTab", title: "Redirect To 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: "reverseTab", title: "Redirect To Original", contexts: ["browser_action"] })
|
||||
|
||||
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: "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"] })
|
||||
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: "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) {
|
||||
if (!isChrome) {
|
||||
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: "reverseBookmarkInNewTab",
|
||||
|
@ -167,9 +177,9 @@ if (!isChrome) {
|
|||
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 => {
|
||||
browser.contextMenus.onClicked.addListener(async info => {
|
||||
switch (info.menuItemId) {
|
||||
case "switchInstanceTab": {
|
||||
const url = new URL(info.pageUrl)
|
||||
|
@ -307,6 +317,8 @@ browser.contextMenus.onClicked.addListener(async info => {
|
|||
return
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<script>
|
||||
export let checked
|
||||
export let onChange
|
||||
console.log(document.body.dir)
|
||||
</script>
|
||||
|
||||
<input class={document.body.dir} {...$$restProps} bind:checked on:change={onChange} type="checkbox" />
|
||||
|
|
|
@ -14,14 +14,31 @@
|
|||
const unsubscribe = options.subscribe(val => (_options = val))
|
||||
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))
|
||||
$: if (bookmarksPermission) {
|
||||
}
|
||||
})
|
||||
|
||||
let bookmarksPermission
|
||||
$: if (disableBookmarks !== null && disableBookmarks === false) {
|
||||
if (bookmarksPermission) {
|
||||
browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r))
|
||||
} else {
|
||||
browser.permissions.remove({ permissions: ["bookmarks"] })
|
||||
bookmarksPermission = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
@ -68,10 +85,12 @@
|
|||
/>
|
||||
</Row>
|
||||
|
||||
{#if disableBookmarks === false}
|
||||
<Row>
|
||||
<Label>{browser.i18n.getMessage("bookmarksMenu") || "Bookmarks menu"}</Label>
|
||||
<Checkbox bind:checked={bookmarksPermission} />
|
||||
</Row>
|
||||
{/if}
|
||||
|
||||
<Exceptions />
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
async function pingInstances() {
|
||||
pingCache = {}
|
||||
for (const instance of allInstances) {
|
||||
console.log("pinging...", instance)
|
||||
pingCache[instance] = { color: "lightblue", value: "pinging..." }
|
||||
const time = await utils.ping(instance)
|
||||
pingCache[instance] = colorTime(time)
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
<div>
|
||||
<Row>
|
||||
<Label>
|
||||
Service:
|
||||
<a href={serviceConf.url} target="_blank" rel="noopener noreferrer">{serviceConf.url}</a>
|
||||
<a href={serviceConf.url} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
|
||||
{browser.i18n.getMessage("service") || "Service"}
|
||||
</a>
|
||||
</Label>
|
||||
<div dir="ltr">
|
||||
<SvelteSelect
|
||||
|
@ -91,9 +92,8 @@
|
|||
|
||||
<Row>
|
||||
<Label>
|
||||
{browser.i18n.getMessage("frontend") || "Frontend"}:
|
||||
<a href={frontendWebsite} target="_blank" rel="noopener noreferrer">
|
||||
{frontendWebsite}
|
||||
<a href={frontendWebsite} style="text-decoration: underline;" target="_blank" rel="noopener noreferrer">
|
||||
{browser.i18n.getMessage("frontend") || "Frontend"}
|
||||
</a>
|
||||
</Label>
|
||||
<div dir="ltr">
|
||||
|
|
|
@ -41,7 +41,14 @@
|
|||
|
||||
<div class={document.body.dir}>
|
||||
{#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>
|
||||
<RedirectIcon />
|
||||
</Row>
|
||||
|
@ -50,7 +57,10 @@
|
|||
{#if switchInstance}
|
||||
<Row
|
||||
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>
|
||||
<SwitchInstanceIcon />
|
||||
|
@ -62,7 +72,13 @@
|
|||
<Label>{browser.i18n.getMessage("copyOriginal") || "Copy Original"}</Label>
|
||||
<CopyIcon />
|
||||
</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>
|
||||
<RedirectToOriginalIcon />
|
||||
</Row>
|
||||
|
@ -85,7 +101,13 @@
|
|||
|
||||
<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>
|
||||
<SettingsIcon />
|
||||
</Row>
|
||||
|
|
|
@ -28,7 +28,10 @@
|
|||
<div
|
||||
class="interactive"
|
||||
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 }} />
|
||||
<Label>{_config.services[serviceKey].name}</Label>
|
||||
|
|
Loading…
Reference in New Issue