From 8f6ccda803b89ad9e7bf546886fb9e031fe9fcee Mon Sep 17 00:00:00 2001 From: Er2 Date: Sun, 20 Mar 2022 19:13:21 +0300 Subject: [PATCH] chrome support, hot injection --- btfl.css | 12 ++++++++---- js/bg.js | 18 ++++++++++++++++++ js/inj.js | 18 ++++++++++++++++++ LICENSE => license | 0 manifest.json | 26 ++++++++++++++++---------- 5 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 js/bg.js create mode 100644 js/inj.js rename LICENSE => license (100%) diff --git a/btfl.css b/btfl.css index dc4ac02..50d4ac5 100644 --- a/btfl.css +++ b/btfl.css @@ -18,6 +18,7 @@ [class^="unreadPill-"], [class^="applicationInstall"], [class*="nitro"], +[class*="artwork-"], div[class^="art-"], div[class^="threadSuggestionBar-"], div[class^="nameTag-"], @@ -33,6 +34,7 @@ div[class*="goal"], div[class^="welcomeCTA-"], h2[class^="privateChannelsHeaderContainer"], nav[class^="nav-"], +span[class^="questionMark-"], /* Settings */ div[aria-controls*="nitro"], @@ -63,10 +65,10 @@ nav[class^="privateChannels-"] div div /* main page */ #app-mount div:not([class]) div[class=""] div:not([class]) { - all: unset; - display: none; - width: 0; - height: 0; + all: unset !important; + display: none !important; + width: 0 !important; + height: 0 !important; } div[aria-label="Servers"] ~ div { @@ -134,6 +136,7 @@ div[class^="radioBar-"] { } /* rounder */ +[class^="authBox"], div[class^="item-"], div[class^="select-"], div[class^="popout"], @@ -169,6 +172,7 @@ div[class^="colorPicker"] div div[class^="saturation"] div, div[class*="input"], input[class^="inputDefault-"], [class^="avatar-"], +div[class^="role-"], div[class^="menu-"] div { border-radius: 8px !important; diff --git a/js/bg.js b/js/bg.js new file mode 100644 index 0000000..6a1a112 --- /dev/null +++ b/js/bg.js @@ -0,0 +1,18 @@ +/** DisKort + * (c) Er2 2022 + * Zlib License + */ + +// Disable CSP +function onHeaders(det) { + for (var i = 0; i < det.responseHeaders.length; i++) { + if (det.responseHeaders[i].name.toLowerCase() == 'content-security-policy' + || det.responseHeaders[i].name.toLowerCase() == 'content-security-policy-report-only' + ) det.responseHeaders[i].value = ''; + } + return { responseHeaders: det.responseHeaders }; +} + +chrome.webRequest.onHeadersReceived.addListener( + onHeaders, {urls: ['']}, ['blocking', 'responseHeaders'] +); diff --git a/js/inj.js b/js/inj.js new file mode 100644 index 0000000..86604c1 --- /dev/null +++ b/js/inj.js @@ -0,0 +1,18 @@ +/** DisKort + * (c) Er2 2022 + * Zlib License + */ + +const base = "https://raw.githubusercontent.com/Er2ch/diskort/main/"; + +async function inject() { + try { + var resp = await fetch(base + 'btfl.css'); + var text = await resp.text(); + var s = document.createElement("style"); + s.innerHTML = text; + document.head.appendChild(s); + } catch(e) { console.error(e); } +} +document.addEventListener("click", inject); +inject(); diff --git a/LICENSE b/license similarity index 100% rename from LICENSE rename to license diff --git a/manifest.json b/manifest.json index 2cabd59..5b0f91f 100644 --- a/manifest.json +++ b/manifest.json @@ -9,20 +9,26 @@ "48": "ext.png" }, - "content_scripts": [ - { - "matches": [ - "*://discord.com/*", - "*://discord.gg/*", - "*://discord.gift/*" - ], - "css": ["btfl.css"] - } + "permissions": [ + "https://raw.githubusercontent.com/Er2ch/diskort/*", + "*://discord.com/", + "webRequest", + "webRequestBlocking" ], + "background": { + "scripts": ["js/bg.js"], + "persistent": true + }, + + "content_scripts": [{ + "matches": ["*://discord.com/*"], + "js": ["js/inj.js"] + }], + "browser_specific_settings": { "gecko": { - "id": "diskort@er2" + "id": "{7e79557e-5773-4be8-b0e2-9e35b34b692c}" } } }