Skip to content
Snippets Groups Projects
Commit ea2f8ec2 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Got show-alternate working.

parent bc635fcb
No related branches found
No related tags found
No related merge requests found
// ==UserScript== // ==UserScript==
// @name Show alternate links // @name Show alternate links
// @namespace http://hugo.hornquist.se // @namespace http://hugo.hornquist.se
// @version 0.1.1 // @version 0.2.0
// @description Show alternate links // @description Show alternate links
// @author hugo@lysator.liu.se // @author hugo@lysator.liu.se
// @match *://* // @match *://*/*
// @updateURL https://git.lysator.liu.se/hugo/web-monkey-scripts/raw/master/show-alternate/index.js // @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 // @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 // @source https://git.lysator.liu.se/hugo/web-monkey-scripts/-/tree/master/show-alternate
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
(function () { (function () {
'use strict'; 'use strict';
let id = `id-${Math.random()}` let id = `id-${Math.floor(Math.random() * 1e6)}`
let outer = document.createElement('div'); let outer = document.createElement('div');
let inner = document.createElement('div'); let inner = document.createElement('div');
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
outer.appendChild(inner); outer.appendChild(inner);
inner.appendChild(ul); inner.appendChild(ul);
let link_count = 0
for (let link of document.querySelectorAll('link[rel=alternate]')) { for (let link of document.querySelectorAll('link[rel=alternate]')) {
link_count++
let li = document.createElement('li'); let li = document.createElement('li');
let a = document.createElement('a') let a = document.createElement('a')
a.href = link.href a.href = link.href
...@@ -32,13 +34,31 @@ ...@@ -32,13 +34,31 @@
ul.appendChild(li) ul.appendChild(li)
} }
if (link_count > 0) {
document.body.appendChild(outer)
}
GM_addStyle(` GM_addStyle(`
#${id} { #${id} {
margin: 0 !important; margin: 0 !important;
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
display: block;
width: 2em;
min-height: 2em;
background: red; background: red;
color: white;
font-weight: bold;
padding: 1ex;
}
#${id}:hover {
width: unset;
}
#${id} ul {
padding: revert;
} }
#${id} > div { #${id} > div {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment