-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWiki_Scripts.user.js
More file actions
66 lines (55 loc) · 2.26 KB
/
Copy pathWiki_Scripts.user.js
File metadata and controls
66 lines (55 loc) · 2.26 KB
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
62
63
64
65
66
// ==UserScript==
// @name Wiki Popup / Styles
// @namespace SkyColtNinja/userscripts
// @version 1.2.4
// @updateURL https://raw.githubusercontent.com/jinks908/tm-scripts/main/Wiki_Scripts.user.js
// @downloadURL https://raw.githubusercontent.com/jinks908/tm-scripts/main/Wiki_Scripts.user.js
// @description Hide Wikipedia popups when using Tridactyl hints
// @author SkyColtNinja
// @match https://en.wikipedia.org/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wikipedia.org
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
// #:# Styles / Fixes
// #;# ------------------------------------------------------------ #
// ## Fix MathML/SVG expression backgrounds
const tables = document.querySelectorAll('table');
tables.forEach(table => {
if (table.querySelector('.mwe-math-element')) {
// Note that Wiki's native dark theme inverts colors, hence 'white' -> 'black'
table.style.setProperty('background-color', 'white', 'important');
};
});
// #:# Hide cookie notice banners
const cnoticeBanners = document.querySelectorAll('.cnotice');
cnoticeBanners.forEach(banner => {
banner.style.setProperty('display', 'none', 'important');
});
// #:# Fix popup persistence when using Tridactyl hints
// Hint mode active flag
let hintModeActive = false;
// Watch for Tridactyl hints appearing and disappearing
const observer = new MutationObserver(() => {
const hints = document.querySelectorAll('.TridactylHintElem');
if (hints.length > 0) {
hintModeActive = true;
} else if (hintModeActive) {
// Hints just disappeared (hint mode just exited)
hintModeActive = false;
// Hide any popups that appeared
setTimeout(() => {
const popups = document.querySelectorAll('.mwe-popups');
popups.forEach(popup => {
popup.style.setProperty('display', 'none', 'important');
popup.remove(); // Also remove it from DOM
});
}, 800);
};
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();