-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwikipedia.js
42 lines (36 loc) · 1.21 KB
/
wikipedia.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
// ==UserScript==
// @name Wikipedia
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description try to take over the world!
// @author LeonAM
// @match https://es.wikipedia.org/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wikipedia.org
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
/** Highlight CSS class name for highlighting */
const HIGHLIGHT_THEME = "tm_highlight";
GM_addStyle(`.${HIGHLIGHT_THEME} {
background-color: lightyellow;
border-radius: 10px;
padding-left: 10px;
}
.${HIGHLIGHT_THEME}::marker { color: white; }`);
const HIGHLIGHT_WORDS = ["futbolista", "argentin"];
/**
* Highlights elements with certain words
*/
function highlightWords() {
let root = document.getElementById("main-cur");
if (!root)
throw new Error("Root element not found (id=\"main-cur\")");
Array.from(root.querySelectorAll("li")).forEach(li => {
if (HIGHLIGHT_WORDS.some(word => li.innerText.includes(word))) {
li.classList.add(HIGHLIGHT_THEME, "notheme");
}
});
}
highlightWords();
})();