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==
// @name Show alternate links
// @namespace http://hugo.hornquist.se
// @version 0.1.1
// @version 0.2.0
// @description Show alternate links
// @author hugo@lysator.liu.se
// @match *://*
// @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
......@@ -14,7 +14,7 @@
(function () {
'use strict';
let id = `id-${Math.random()}`
let id = `id-${Math.floor(Math.random() * 1e6)}`
let outer = document.createElement('div');
let inner = document.createElement('div');
......@@ -23,7 +23,9 @@
outer.appendChild(inner);
inner.appendChild(ul);
let link_count = 0
for (let link of document.querySelectorAll('link[rel=alternate]')) {
link_count++
let li = document.createElement('li');
let a = document.createElement('a')
a.href = link.href
......@@ -32,21 +34,39 @@
ul.appendChild(li)
}
GM_addStyle(`
#${id} {
margin: 0 !important;
position: absolute;
top: 0;
right: 0;
background: red;
if (link_count > 0) {
document.body.appendChild(outer)
}
#${id} > div {
display: none;
}
GM_addStyle(`
#${id} {
margin: 0 !important;
position: absolute;
top: 0;
right: 0;
display: block;
width: 2em;
min-height: 2em;
background: red;
color: white;
font-weight: bold;
padding: 1ex;
}
#${id}:hover > div {
display: block;
}
`)
#${id}:hover {
width: unset;
}
#${id} ul {
padding: revert;
}
#${id} > div {
display: none;
}
#${id}:hover > div {
display: block;
}
`)
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment