From b329d30555d7539d4431961ceb690fb321c2c903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se> Date: Thu, 26 Jan 2023 11:05:17 +0100 Subject: [PATCH] Add show alternate. --- show-alternate/index.js | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 show-alternate/index.js diff --git a/show-alternate/index.js b/show-alternate/index.js new file mode 100644 index 0000000..e818cef --- /dev/null +++ b/show-alternate/index.js @@ -0,0 +1,52 @@ +// ==UserScript== +// @name Show alternate links +// @namespace http://hugo.hornquist.se +// @version 0.1.0 +// @description Show alternate links +// @author hugo@lysator.liu.se +// @match * +// @updateURL https://git.lysator.liu.se/hugo/web-monkey-scripts/raw/master/show-alternate/index.js +// @downloadURL https://git.lysator.liu.se/hugo/web-monkey-scripts/raw/master/show-alternate/index.js +// @source https://git.lysator.liu.se/hugo/web-monkey-scripts/-/tree/master/show-alternate +// @grant GM_addStyle +// ==/UserScript== + +(function () { + 'use strict'; + + let id = `id-${Math.random()}` + + let outer = document.createElement('div'); + let inner = document.createElement('div'); + outer.id = id + let ul = document.createElement('ul'); + outer.appendChild(inner); + inner.appendChild(ul); + + for (let link of document.querySelectorAll('link[rel=alternate]')) { + let li = document.createElement('li'); + let a = document.createElement('a') + a.href = link.href + a.textContent = `${link.type} - ${link.title}` + li.appendChild(a) + ul.appendChild(li) + } + + GM_addStyle(` + #${id} { + margin: 0 !important; + position: absolute; + top: 0; + right: 0; + background: red; + } + + #${id} > div { + display: none; + } + + #${id}:hover > div { + display: block; + } + `) +})(); -- GitLab