Skip to content

Commit b8fda0f

Browse files
authored
Merge pull request #987 from VillainsRule/main
fix: potential cloaking fix
2 parents 424420e + 8e41496 commit b8fda0f

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

static/assets/js/home.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,49 @@ if (
1212
localStorage.getItem("ab") === "true"
1313
) {
1414
const popup = open("about:blank", "_blank");
15-
if (!popup || popup.closed) {
16-
alert(
17-
"Please allow popups for this site. Doing so will allow us to open the site in a about:blank tab and preventing this site from showing up in your history. You can turn this off in the site settings.",
18-
);
19-
} else {
20-
const doc = popup.document;
21-
const iframe = doc.createElement("iframe");
22-
const style = iframe.style;
23-
const link = doc.createElement("link");
15+
setTimeout(() => {
16+
if (!popup || popup.closed) {
17+
alert(
18+
"Please allow popups for this site. Doing so will allow us to open the site in a about:blank tab and preventing this site from showing up in your history. You can turn this off in the site settings.",
19+
);
20+
} else {
21+
const doc = popup.document;
22+
const iframe = doc.createElement("iframe");
23+
const style = iframe.style;
24+
const link = doc.createElement("link");
2425

25-
const name = localStorage.getItem("name") || "My Drive - Google Drive";
26-
const icon =
27-
localStorage.getItem("icon") ||
28-
"https://ssl.gstatic.com/docs/doclist/images/drive_2022q3_32dp.png";
26+
const name = localStorage.getItem("name") || "My Drive - Google Drive";
27+
const icon =
28+
localStorage.getItem("icon") ||
29+
"https://ssl.gstatic.com/docs/doclist/images/drive_2022q3_32dp.png";
2930

30-
doc.title = name;
31-
link.rel = "icon";
32-
link.href = icon;
31+
doc.title = name;
32+
link.rel = "icon";
33+
link.href = icon;
3334

34-
iframe.src = location.href;
35-
style.position = "fixed";
36-
style.top = style.bottom = style.left = style.right = 0;
37-
style.border = style.outline = "none";
38-
style.width = style.height = "100%";
35+
iframe.src = location.href;
36+
style.position = "fixed";
37+
style.top = style.bottom = style.left = style.right = 0;
38+
style.border = style.outline = "none";
39+
style.width = style.height = "100%";
3940

40-
doc.head.appendChild(link);
41-
doc.body.appendChild(iframe);
41+
doc.head.appendChild(link);
42+
doc.body.appendChild(iframe);
4243

43-
const pLink = localStorage.getItem(encodeURI("pLink")) || getRandomUrl();
44-
location.replace(pLink);
44+
const pLink = localStorage.getItem(encodeURI("pLink")) || getRandomUrl();
45+
location.replace(pLink);
4546

46-
const script = doc.createElement("script");
47-
script.textContent = `
47+
const script = doc.createElement("script");
48+
script.textContent = `
4849
window.onbeforeunload = function (event) {
4950
const confirmationMessage = 'Leave Site?';
5051
(event || window.event).returnValue = confirmationMessage;
5152
return confirmationMessage;
5253
};
5354
`;
54-
doc.head.appendChild(script);
55-
}
55+
doc.head.appendChild(script);
56+
}
57+
}, 5000);
5658
}
5759
// Particles
5860
document.addEventListener("DOMContentLoaded", event => {

0 commit comments

Comments
 (0)