File size: 3,177 Bytes
01fcadf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
//Tab specific settings.
import { type AbCloaks, type TabCloaks } from "./types";
const TabSettings = {
    tabCloak: "nebula||tabCloak",
    abblob: "nebula||abBlob"
};

function cloak(cloak: AbCloaks | string, redirect: string, url: string) {
    switch (cloak) {
        case "a:b":
            window.location.replace(redirect);
            const win = window.open();
            win!.document.body.style.margin = "0";
            win!.document.body.style.height = "100vh";
            const iframe = win!.document.createElement("iframe");
            iframe.style.border = "none";
            iframe.style.width = "100%";
            iframe.style.height = "100%";
            iframe.style.margin = "0";
            iframe.src = url;
            win!.document.body.appendChild(iframe);
            break;
        case "blob":
            const htmlContent = `

                <!DOCTYPE html>

                <html>

                <head>

                <style type="text/css">

                body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; }

                </style>

                </head>

                <body>

                <iframe style="border: none; width: 100%; height: 100vh;" src="${window.location.href}"></iframe>

                </body>

                </html>

            `;
            window.location.replace("https://google.com");
            const blob = new Blob([htmlContent], { type: "text/html" });
            const blobURL = URL.createObjectURL(blob);
            window.open(blobURL, "_blank");
            break;
    }
}

const tabSettings = {
    cloakTab: function (cloak: TabCloaks | string) {
        const faviconElement = document.getElementById("favicon") as HTMLLinkElement;
        localStorage.setItem(TabSettings.tabCloak, cloak);
        switch (cloak) {
            case "google":
                document.title = "Google";
                faviconElement.href = "/cloaks/google.png";
                break;
            case "wikipedia":
                document.title = "Wikipedia";
                faviconElement.href = "/cloaks/wikipedia.ico";
                break;
            case "canvas":
                document.title = "Dashboard";
                faviconElement.href = "/cloaks/canvas.ico";
                break;
            case "classroom":
                document.title = "Home";
                faviconElement.href = "/cloaks/classroom.png";
                break;
            case "powerschool":
                document.title = "PowerSchool";
                faviconElement.href = "/cloaks/ps.ico";
                break;
            case "reset":
                //force a reset of favicon & title
                localStorage.setItem("nebula||tabCloak", "default");
                window.location.reload();
            default:
                return;
        }
    },
    abCloak: function (type: AbCloaks | string) {
        localStorage.setItem(TabSettings.abblob, type);
        cloak(type as AbCloaks, "https://google.com", window.location.href);
    }
};
export { tabSettings, TabSettings, cloak };