-
Notifications
You must be signed in to change notification settings - Fork 0
/
hide-furigana.js
61 lines (48 loc) · 1.92 KB
/
hide-furigana.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 Hide Furigana in Jisho Sentences
// @version 0.2
// @description Enables a link to toggle between Furigana On/Off in the page of sentences at Jisho.org
// @author jarmanso7
// @match https://jisho.org/search/*#sentences*
// @match https://jisho.org/search/*%20%23sentences*
// @namespace https://greasyfork.org/users/241544
// ==/UserScript==
function AddToggleFuriganaLink(){
/* ------------------------ GENERATE CUSTOM LINK ---------------------*/
var addToggleFuriganaLink = document.createElement ('a');
addToggleFuriganaLink.setAttribute ('id', 'toggle-furigana-custom-link');
addToggleFuriganaLink.setAttribute ('class', 'concept_light-status_link');
addToggleFuriganaLink.innerText = 'Furigana off';
var sentences = document.getElementsByClassName("sentences")[0]
var hrDivider = document.createElement ( 'hr' );
sentences.insertBefore(hrDivider, sentences.firstChild);
sentences.insertBefore(addToggleFuriganaLink, sentences.firstChild);
/* ------------------------ ACTIVATE CUSTOM LINK ---------------------*/
document.getElementById ('toggle-furigana-custom-link').addEventListener(
'click', ButtonClickAction, false
);
function ButtonClickAction (zEvent) {
ToggleFuriganaEvent();
}
}
function ToggleFuriganaEvent(){
var furiganaLink = document.getElementById ('toggle-furigana-custom-link');
if (furiganaLink.innerText == 'Furigana off'){
LoopThroughFuriganaTagsChangeDisplayProperty('none');
furiganaLink.innerText = 'Furigana on';
}
else {
LoopThroughFuriganaTagsChangeDisplayProperty('block');
furiganaLink.innerText = 'Furigana off';
}
}
function LoopThroughFuriganaTagsChangeDisplayProperty(displayValue){
var furiganaTags = document.getElementsByClassName("furigana");
for (var i = 0; i < furiganaTags.length; i++) {
furiganaTags[i].style.display = displayValue;
}
}
//Main function
(function() {
AddToggleFuriganaLink();
})();