From 7e7485414de83c7529a53fe1f402b76aab574a70 Mon Sep 17 00:00:00 2001 From: RandomTechChannel <140035326+OG-RandomTechChannel@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:42:14 +0800 Subject: [PATCH] upgraded to ManifestV3 --- src/SEQTA.js | 70 ++++++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/src/SEQTA.js b/src/SEQTA.js index 8a370f68..be595719 100644 --- a/src/SEQTA.js +++ b/src/SEQTA.js @@ -1,16 +1,3 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - var isChrome = window.chrome; var SettingsClicked = false var MenuOptionsOpen = false; @@ -18,10 +5,11 @@ var UserInitalCode = ''; var currentSelectedDate = new Date(); var WhatsNewOpen = false; var LessonInterval; - -var stringToHTML = function (str) { +var stringToHTML = function (str, styles=false) { var parser = new DOMParser(); + var str = DOMPurify.sanitize(str, { ADD_ATTR: ['onclick']}); var doc = parser.parseFromString(str, "text/html"); + if(styles){doc.body.style.cssText = "height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);"} return doc.body; }; @@ -81,10 +69,6 @@ const ShortcutLinks = { link: "https://netflix.com", viewBox: "0 0 24 24", icon: "M6.5,2H10.5L13.44,10.83L13.5,2H17.5V22C16.25,21.78 14.87,21.64 13.41,21.58L10.5,13L10.43,21.59C9.03,21.65 7.7,21.79 6.5,22V2Z" - }, - EducationPerfect: { - link: "https://app.educationperfect.com", - viewBox: "0 0 24 24", } } @@ -251,10 +235,8 @@ function OpenWhatsNewPopup() { text = stringToHTML( `
-

3.0.3 - The settings pannel was blank except for the about -

3.0.2 - The custom shortcut feature wasn't working -

3.0.1 - Bug fixes and removing redundant code -

3.0.0 - The beginning of BestSEQTA, I am forking the project to take it in a new direction +

3.0.1 - Bug fixes and working on manifest V3

+

3.0.0 - Started BestSEQTA

2.0.7 - Added support to other domains + Minor bug fixes

  • Fixed BestSEQTA not loading on some pages
  • Fixed text colour of notices being unreadable
  • Fixed pages not reloading when saving changes
  • 2.0.2 - Minor bug fixes

  • Fixed indicator for current lesson
  • Fixed text colour for DM messages list in Light mode
  • Fixed user info text colour
  • Sleek New Layout

  • Updated with a new font and presentation, BestSEQTA has never looked better.
  • @@ -273,13 +255,15 @@ function OpenWhatsNewPopup() {
    Report bugs and feedback: - +
    +
    Support me: Buy Me a Coffee at ko-fi.com
    +
    `).firstChild exitbutton = document.createElement('div') @@ -507,7 +491,7 @@ function LoadPageElements() { "notifications__bubble___1EkSQ" )[0]; if (typeof alertdiv == 'undefined') { - console.log("[BestSEQTA] Your inbox is clean") + console.log("[BestSEQTA] No notifications currently") } else { @@ -561,7 +545,7 @@ function LoadPageElements() { "notifications__bubble___1EkSQ" )[0]; if (typeof alertdiv == 'undefined') { - console.log("[BestSEQTA] Your inbox is clean") + console.log("[BestSEQTA] No notifications currently") } else { @@ -848,7 +832,7 @@ function RunFunctionOnTrue(storedSetting) { document.documentElement.style.setProperty('--text-primary', "black"); } - document.querySelector('link[rel*="icon"]').href = chrome.extension.getURL("icons/icon-48.png"); + document.querySelector('link[rel*="icon"]').href = chrome.runtime.getURL("icons/icon-48.png"); rbg = GetThresholdofHex(storedSetting.selectedColor); if (rbg > 210) { @@ -926,7 +910,7 @@ document.addEventListener( console.log("[BestSEQTA] Verified SEQTA Page"); var link = document.createElement("link"); - link.href = chrome.extension.getURL("inject/documentload.css"); + link.href = chrome.runtime.getURL("inject/documentload.css"); link.type = "text/css"; link.rel = "stylesheet"; document.getElementsByTagName("html")[0].appendChild(link); @@ -1007,7 +991,7 @@ function RunExtensionSettingsJS() { } function FindSEQTATab() { - chrome.runtime.sendMessage({ type: "ReloadTabs", }); + chrome.runtime.sendMessage({ type: "reloadTabs", }); } /* Store the currently selected settings using chrome.storage.local. @@ -1063,11 +1047,6 @@ function RunExtensionSettingsJS() { } } - var stringtoHTML = function (str) { - var parser = new DOMParser(); - var doc = parser.parseFromString(str, "text/html"); - return doc.body; - }; function CreateShortcutDiv(name) { @@ -1289,8 +1268,8 @@ function CallExtensionSettings() {

    About

    -

    Developed and maintained by RTC

    -

    BestSEQTA is a fork of the project called betterSEQTA, The betterSEQTA project is dead, this is here to add features and improve the experience

    +

    Created and developed and maintained by Nulkem

    +

    BestSEQTA is a fork of the project BetterSEQTA, BetterSEQTA is no longer supported so we are here to fill that gap!

    @@ -1320,8 +1299,7 @@ function CallExtensionSettings() {
    -

    - +
    @@ -1469,7 +1447,7 @@ function CallExtensionSettings() {

    Animated Background

    -

    Adds an animated background to BestSEQTA.

    +

    Adds an animated background to BestSEQTA. (May impact battery life)

    @@ -1515,7 +1493,7 @@ function CallExtensionSettings() {
    -

    Forked by RTC

    +

    Created by Nulkem

    What's new in v${chrome.runtime.getManifest().version}

    `) @@ -2181,8 +2159,8 @@ function hexToRGB(hex) { } function GetThresholdofHex(hex) { - rbg = hexToRGB(hex) - return Math.sqrt(rbg.r ** 2 + rbg.g ** 2 + rbg.b ** 2) + var rgb = hexToRGB(hex) + return Math.sqrt(rgb.r ** 2 + rgb.g ** 2 + rgb.b ** 2) } function CheckCurrentLessonAll(lessons) { @@ -2822,7 +2800,7 @@ function AddCustomShortcutsToPage() { function SendHomePage() { setTimeout(function () { // Sends the html data for the home page - console.log("[BestSEQTA] Loading Home Page"); + console.log("[BestSEQTA] Started Loading Home Page"); document.title = "Home ― SEQTA Learn"; var element = document.querySelector("[data-key=home]"); @@ -2835,7 +2813,7 @@ function SendHomePage() { const titlediv = document.getElementById('title').firstChild; titlediv.innerText = "Home"; - document.querySelector('link[rel*="icon"]').href = chrome.extension.getURL("icons/icon-48.png"); + document.querySelector('link[rel*="icon"]').href = chrome.runtime.getURL("icons/icon-48.png"); currentSelectedDate = new Date(); @@ -3041,7 +3019,7 @@ function SendHomePage() { ); NewNotice.append(staff.firstChild); // Converts the string into HTML - var content = stringToHTML(NoticesPayload.payload[i].contents); + var content = stringToHTML(NoticesPayload.payload[i].contents, styles=true); for (let i = 0; i < content.childNodes.length; i++) { NewNotice.append(content.childNodes[i]); } @@ -3095,7 +3073,7 @@ function SendHomePage() { "notifications__bubble___1EkSQ" )[0]; if (typeof alertdiv == 'undefined') { - console.log("[BestSEQTA] Your inbox is clean") + console.log("[BestSEQTA] No notifications currently") } else {