-
Notifications
You must be signed in to change notification settings - Fork 0
/
wikipediaplain.user.js
61 lines (48 loc) · 1.55 KB
/
wikipediaplain.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==UserScript==
// @name Wikipedia Plain
// @namespace http://github.com/shajith
// @description Remove everything but content from wikipedia.
// @include http://en.wikipedia.org/wiki/*
// @include http://*.wikipedia.org/wiki/*
// ==/UserScript==
function toggleElems(arr, hide) {
for(i=0; i < arr.length; i++) {
if(hide) {
arr[i].style.display = "none";
}
else {
arr[i].style.display = "";
}
}
}
function hideElems(e) {
toggleElems(hidden_elements, false);
e.preventDefault();
show_ui_button = document.getElementById('show_ui_button');
show_ui_button.parentNode.removeChild(show_ui_button);
return false;
}
function nodeListAsArray(nodeList) {
ret = [];
for(i=0;i<nodeList.length;i++) {
ret.push(nodeList[i]);
}
return ret;
}
var hidden_elements = nodeListAsArray(document.querySelectorAll("#p-namespaces, #right-navigation, #p-personal"));
hidden_elements = hidden_elements.concat(nodeListAsArray(document.querySelectorAll(".editsection")));
var sidebar = document.getElementById("mw-panel");
for(i=0; i < sidebar.children.length; i++) {
elem = sidebar.children[i];
console.log(elem.id);
if(elem.id != "p-logo") {
hidden_elements.push(elem);
}
}
toggleElems(hidden_elements, true);
d=document.createElement("div");
d.style.textAlign = "center";
d.style.fontSize = "smaller";
d.innerHTML = '<a href="#" id="show_ui_button">Show UI</a>';
document.getElementById("p-logo").parentNode.appendChild(d);
document.getElementById("show_ui_button").onclick = hideElems;