/
content-broken-vsaved.js
executable file
·91 lines (69 loc) · 4.24 KB
/
content-broken-vsaved.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
$("body").wrapInner("<div id='#innerBody' style='background-color:#fff;'></div>", function () {
$("#innerbody").before("<div id='#loadingGif' style='position: fixed;left: 0px;top: 0px;width: 100%;height: 100%;z-index: 9999; background: url(loading.gif) center no-repeat #fff;'></div>", function () {
$("#innerBody").fadeOut("fast", function () {
$("#loadingGif").fadeIn("fast", function () {
var pElements = document.querySelectorAll('p', 'tr', 'th', 'li', 'a');
asyncLoop(pElements.length, function (loop) {
var element = pElements[loop.iteration()];
asyncLoop(element.childNodes.length, function (loop2) {
var node = element.childNodes[loop2.iteration()];
if (node.nodeType === 3 && node.nodeValue.length >= 8) {
var text = node.nodeValue;
replaceKeyPhrases(text, function (replacedText) {
if (replacedText !== text) {
element.replaceChild(document.createTextNode(replacedText), node);
}
});
}
// log the iteration
console.log(loop2.iteration());
// Okay, for cycle could continue
loop2.next();
},
function () {
console.log('mid-cycle ended')
})
// log the iteration
console.log(loop.iteration());
// Okay, for cycle could continue
loop.next();
},
function () {
var hElements = document.querySelectorAll('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
asyncLoop(hElements.length, function (loop) {
var element = hElements[loop.iteration()];
asyncLoop(element.childNodes.length, function (loop2) {
var node = element.childNodes[loop2.iteration()];
if (node.nodeType === 3 && node.nodeValue.length >= 6) {
var text = node.nodeValue;
getQuote(function (quote) {
if (quote !== text) {
element.replaceChild(document.createTextNode(quote), node);
}
});
}
// log the iteration
console.log(loop2.iteration());
// Okay, for cycle could continue
loop2.next();
},
function () {
console.log('mid-cycle ended')
})
// log the iteration
console.log(loop.iteration());
// Okay, for cycle could continue
loop.next();
},
function () {
$("#loadingGif").fadeOut("fast", function () {
$("#innerBody").fadeIn("fast", function () {});
});
});
}
);
}
);
});
});
});