-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
99 lines (77 loc) · 2.5 KB
/
script.js
File metadata and controls
99 lines (77 loc) · 2.5 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
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
92
93
94
95
96
97
98
99
function firstCheck(url) {
if (url.includes("document") || url.includes("doc")) {
const blurredPages = Array.from(
document.querySelectorAll(".outer_page.blurred_page")
),
blurTemplates = Array.from(document.querySelectorAll(".blur")),
promoWallpaper = Array.from(document.querySelectorAll(".promo_wrapper"));
for (let template of blurTemplates) {
template.remove();
}
for (let promo of promoWallpaper) {
promo.remove();
}
for (let page of blurredPages) {
const childPage = page.querySelector(".newpage");
if (childPage == null) continue;
Array.from(childPage.children).forEach((child) => {
child.style.textShadow = "black 0px 0px 0px";
});
childPage?.nextElementSibling?.remove();
}
}
}
function secondCheck(url) {
if (url.includes("document")) {
const takeDocumentWrapper = document.querySelector("#document-wrapper");
if (takeDocumentWrapper == null) return;
const documentWrapperNodes = Array.from(takeDocumentWrapper.children);
// removes fixed watermark on documents
for (let child of documentWrapperNodes) {
if (
child.nodeName === "DIV" &&
child.firstChild?.id !== "page-container-wrapper"
) {
child.remove();
}
}
const documentContainer = document.querySelector("#page-container"),
documentsCopy = Array.from(documentContainer.children);
// removes watermarks from blurred documents
for (let document of documentsCopy) {
if (Array.from(document.children).length > 1) {
document.lastChild.remove();
}
}
documentContainer.innerHTML = documentContainer.innerHTML
.replace(/(display:( ?)none(;?)|filter:( ?)blur\(4px\)(;?)|user-select:( ?)none(;?))/gm, "");
}
}
function thirdCheck() {
const blurRemover = (htmlElement) => {
htmlElement.style.filter = '';
htmlElement.style.userSelect = '';
htmlElement.style.textShadow = 'black 0px 0px 0px';
const children = Array.from(htmlElement.children);
if(children.length > 0) {
for(let child of children) {
blurRemover(child);
};
}
}
if(document.body) {
blurRemover(document.body);
}
}
(function () {
const url = window.location.href,
availableSites = url.toLocaleLowerCase().match(/(scribd|studocu)/gm) || [''];
switch (availableSites[0]) {
case "scribd":
return firstCheck(url);
case "studocu":
return secondCheck(url);
default:
return thirdCheck();
}
})();