From 318242099b64f847bda470ad5f09728265d76e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 14 Sep 2017 21:49:21 +0200 Subject: [PATCH] Wikipedia: deep remove all links, hide references --- src/wikipedia.js | 21 ++++++++------------- style.css | 3 +++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/wikipedia.js b/src/wikipedia.js index 63011348..44188ac9 100644 --- a/src/wikipedia.js +++ b/src/wikipedia.js @@ -1,21 +1,16 @@ function stripLinks (dom) { - var current = dom.firstChild + var as = dom.getElementsByTagName('a') + var as = Array.prototype.slice.call(as) - while (current) { - var next = current.nextSibling + as.forEach(function (current) { + var c - if (current.tagName === 'A') { - var c - - while (c = current.firstChild) { - dom.insertBefore(c, current) - } - - dom.removeChild(current) + while (c = current.firstChild) { + current.parentNode.insertBefore(c, current) } - current = next - } + current.parentNode.removeChild(current) + }) } function prepare (text) { diff --git a/style.css b/style.css index 1d21d020..aef4bb04 100644 --- a/style.css +++ b/style.css @@ -508,3 +508,6 @@ a.showDetails { .wikipedia h4 { clear: left; } +.wikipedia .reference { + display: none; +}