mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Migrate to new reader command
`:reader --old` retained for old behaviour
This commit is contained in:
parent
cc59b83bee
commit
93352f08b5
1 changed files with 27 additions and 7 deletions
|
@ -2292,11 +2292,15 @@ export async function zoom(level = 0, rel = "false", tabId = "auto") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Opens the current page in Firefox's reader mode.
|
/**
|
||||||
* You currently cannot use Tridactyl while in reader mode.
|
* @hidden
|
||||||
|
* Old version of the reader command. Opens the current page in Firefox's reader mode.
|
||||||
|
* You cannot use Tridactyl while in this reader mode.
|
||||||
|
*
|
||||||
|
* Use [[reader]] instead
|
||||||
*/
|
*/
|
||||||
//#background
|
//#background
|
||||||
export async function reader() {
|
export async function readerold() {
|
||||||
if (await firefoxVersionAtLeast(58)) {
|
if (await firefoxVersionAtLeast(58)) {
|
||||||
const aTab = await activeTab()
|
const aTab = await activeTab()
|
||||||
if (aTab.isArticle) {
|
if (aTab.isArticle) {
|
||||||
|
@ -5989,14 +5993,30 @@ export async function extoptions(...optionNameArgs: string[]) {
|
||||||
//#content_helper
|
//#content_helper
|
||||||
import { Readability } from "@mozilla/readability"
|
import { Readability } from "@mozilla/readability"
|
||||||
|
|
||||||
//#content
|
//#content_helper
|
||||||
export async function reader2() {
|
export async function readerurl() {
|
||||||
document.querySelectorAll(".TridactylStatusIndicator").forEach(ind => ind.parentNode.removeChild(ind))
|
document.querySelectorAll(".TridactylStatusIndicator").forEach(ind => ind.parentNode.removeChild(ind))
|
||||||
const article = new Readability(document).parse()
|
const article = new Readability(document).parse()
|
||||||
article["link"] = window.location.href
|
article["link"] = window.location.href
|
||||||
|
return browser.runtime.getURL("static/reader.html#" + btoa(encodeURIComponent(JSON.stringify(article))))
|
||||||
|
}
|
||||||
|
|
||||||
// todo: sanitise
|
//#content
|
||||||
open(browser.runtime.getURL("static/reader.html#" + btoa(encodeURIComponent(JSON.stringify(article)))))
|
export async function reader(...args: string[]) {
|
||||||
|
switch(args[0]) {
|
||||||
|
case "--old":
|
||||||
|
readerold()
|
||||||
|
break
|
||||||
|
case "--tab":
|
||||||
|
tabopen(await readerurl())
|
||||||
|
break
|
||||||
|
case "--window":
|
||||||
|
winopen(await readerurl())
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
open(await readerurl())
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue