From 25b44e8f5c0aebee2ccc4de8c6c0d6a45125a84e Mon Sep 17 00:00:00 2001 From: Maddison Hellstrom Date: Tue, 15 Dec 2020 20:46:57 -0800 Subject: [PATCH] [src:feat] add WikiRank binding --- actions.js | 11 +++++++++++ keys.js | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/actions.js b/actions.js index 69b452c..a081d56 100644 --- a/actions.js +++ b/actions.js @@ -704,6 +704,17 @@ actions.wp.toggleSimple = () => { actions.openLink(u.href)() } +actions.wp.viewWikiRank = () => { + const h = document.location.hostname.split(".") + const lang = h.length > 2 && h[0] !== "www" ? h[0] : "en" + const p = document.location.pathname.split("/") + if (p.length < 3 || p[1] !== "wiki") { + return + } + const article = p.slice(2).join("/") + actions.openLink(`https://wikirank.net/${lang}/${article}`, { newTab: true })() +} + // Nest Thermostat Controller // -------------------------- actions.nt = {} diff --git a/keys.js b/keys.js index 9b04001..f6472cb 100644 --- a/keys.js +++ b/keys.js @@ -733,6 +733,11 @@ const maps = { description: "View external link", callback: actions.createHint("a[rel=nofollow]"), }, + { + alias: "R", + description: "View WikiRank for current article", + callback: actions.wp.viewWikiRank, + }, ], "craigslist.org": [