diff --git a/interface/src/App.tsx b/interface/src/App.tsx index 2de98e69..2ee0a92b 100644 --- a/interface/src/App.tsx +++ b/interface/src/App.tsx @@ -6,7 +6,8 @@ import logoDark from './assets/betterseqta-light-full.png'; import Shortcuts from './pages/Shortcuts'; import { useSettingsContext } from './SettingsContext'; import Picker from './components/Picker'; -import Themes from './pages/Themes'; +//import Themes from './pages/Themes'; +import About from './pages/About'; //import About from './pages/About'; const App: React.FC = () => { @@ -31,8 +32,8 @@ const App: React.FC = () => { content: }, { - title: 'Themes', - content: + title: 'About', + content: } ]; diff --git a/interface/src/components/Picker.css b/interface/src/components/Picker.css new file mode 100644 index 00000000..179c6559 --- /dev/null +++ b/interface/src/components/Picker.css @@ -0,0 +1,95 @@ +.dark #rbgcp-wrapper [style="height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ box-sizing\:\ border-box\;"] { + background-color: #37373b !important; +} + +.dark #rbgcp-wrapper [style="height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ box-sizing\:\ border-box\;"] [style="padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ display\:\ flex\;\ align-items\:\ center\;\ justify-content\:\ center\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;"] { + color: white !important; +} + +.dark #rbgcp-wrapper [style="height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ box-sizing\:\ border-box\;"] [style="padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ display\:\ flex\;\ align-items\:\ center\;\ justify-content\:\ center\;\ background\:\ white\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;"] { + background-color: #4b4b53 !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ justify-content\:\ space-between\;\ margin-top\:\ 12px\;\ margin-bottom\:\ -4px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ box-sizing\:\ border-box\;\ padding-left\:\ 0px\;"]:has(svg) { + background-color: #37373b !important; + color: white !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ height\:\ 28px\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ width\:\ 30px\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;\ margin-right\:\ 1px\;"] svg { + filter: invert(); +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ justify-content\:\ space-between\;\ margin-top\:\ 12px\;\ margin-bottom\:\ -4px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ box-sizing\:\ border-box\;\ padding-left\:\ 0px\;"] [style="position\:\ relative\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ align-items\:\ center\;"]:has(svg) { + background: transparent !important; + filter: invert(); + color: #39393b !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ justify-content\:\ space-between\;\ margin-top\:\ 12px\;\ margin-bottom\:\ -4px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ box-sizing\:\ border-box\;\ padding-left\:\ 0px\;"] [style^="display\: "]:has(svg) { + background-color: #3f3f44 !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ box-sizing\:\ border-box\;"] [style="padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ display\:\ flex\;\ align-items\:\ center\;\ justify-content\:\ center\;\ background\:\ white\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;"]:has(svg) { + background-color: #4b4b53 !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ box-sizing\:\ border-box\;"] [style="padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ display\:\ flex\;\ align-items\:\ center\;\ justify-content\:\ center\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;"] svg { + filter: invert(); +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\ 2px\ 2px\ 8px\;"] svg { + filter: invert(); +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\ 2px\ 2px\ 8px\;"] input { + color: white !important; +} + +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"]:has(svg) { + background-color: #37373b !important; +} + +.dark #rbgcp-wrapper [style^="width\: "] [style^="width\: "] { + color: white !important; +} +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"] [style="width\:\ 30px\;\ height\:\ 24px\;\ border-radius\:\ 4px\;\ display\:\ flex\;\ align-items\:\ center\;\ justify-content\:\ center\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;"]:has(svg) svg, +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"] [style="width\:\ 30px\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;\ height\:\ 24px\;\ border-radius\:\ 4px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ position\:\ relative\;"]:has(svg) svg, +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"] [style="width\:\ 30px\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;\ height\:\ 24px\;\ border-radius\:\ 4px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;"]:has(svg) svg { + filter: invert(); +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ justify-content\:\ center\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;"] { + color: white !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ position\:\ relative\;\ padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 86\,\ 86\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ justify-content\:\ center\;\ background\:\ rgba\(255\,\ 255\,\ 255\,\ 0\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\)\ 1px\ 1px\ 3px\;"] { + color: white !important; +} + +.dark #rbgcp-wrapper :last-child > [style$=" relative\;"] [style$=" \31 px\;"] { + filter: none !important; + background-color: #37373b !important; +} + +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ position\:\ relative\;\ padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ justify-content\:\ center\;\ background\:\ white\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;"], +.dark #rbgcp-wrapper [style="display\:\ flex\;\ align-items\:\ center\;\ padding-left\:\ 8px\;\ padding-right\:\ 8px\;\ line-height\:\ 1\;\ border-radius\:\ 4px\;\ font-weight\:\ 700\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ font-size\:\ 12px\;\ height\:\ 24px\;\ transition\:\ all\ 160ms\ ease\ 0s\;\ justify-content\:\ center\;\ background\:\ white\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;"] { + background-color: #3f3f44 !important; +} + +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"] [style="width\:\ 30px\;\ background\:\ white\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;\ height\:\ 24px\;\ border-radius\:\ 4px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;\ position\:\ relative\;"]:has(svg) { + background-color: #3f3f44 !important; +} + +.dark #rbgcp-wrapper [style="height\:\ 216px\;\ width\:\ 100\%\;\ transition\:\ all\ 120ms\ linear\ 0s\;"] [style="text-align\:\ center\;\ color\:\ rgb\(50\,\ 49\,\ 54\)\;\ font-size\:\ 12px\;\ font-weight\:\ 500\;\ margin-top\:\ 3px\;"], +.dark #rbgcp-wrapper [style="height\:\ 216px\;\ width\:\ 100\%\;\ transition\:\ all\ 120ms\ linear\ 0s\;"] [style="text-align\:\ center\;\ color\:\ rgb\(50\,\ 49\,\ 54\)\;\ font-size\:\ 13px\;\ font-weight\:\ 600\;\ position\:\ absolute\;\ top\:\ 6\.5px\;\ left\:\ 2px\;"] { + color: white !important; +} + +.dark #rbgcp-wrapper [style="height\:\ 98px\;\ width\:\ 100\%\;\ transition\:\ all\ 120ms\ linear\ 0s\;"] [style="cursor\:\ ew-resize\;\ position\:\ relative\;"] [style="text-align\:\ center\;color\:\ rgb\(255\,\ 255\,\ 255\)\;font-size\:\ 12px\;font-weight\:\ 500\;line-height\:\ 1\;position\:\ absolute\;left\:\ 50\%\;transform\:\ translate\(-50\%\,\ 0\%\)\;top\:\ 0px\;z-index\:\ 10\;text-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.6\)\ 1px\ 1px\ 1px\;"] { + text-shadow: none !important; + background-color: transparent !important; +} + +.dark #rbgcp-wrapper [style="align-items\:\ center\;\ justify-content\:\ flex-end\;\ height\:\ 28px\;\ background\:\ rgb\(233\,\ 233\,\ 245\)\;\ border-radius\:\ 6px\;\ padding\:\ 2px\;\ display\:\ flex\;\ box-sizing\:\ border-box\;"] [style="width\:\ 30px\;\ background\:\ white\;\ color\:\ rgb\(86\,\ 140\,\ 245\)\;\ box-shadow\:\ rgba\(0\,\ 0\,\ 0\,\ 0\.2\)\ 1px\ 1px\ 3px\;\ height\:\ 24px\;\ border-radius\:\ 4px\;\ display\:\ flex\;\ justify-content\:\ center\;\ align-items\:\ center\;"]:has(svg) { + background-color: #3f3f44 !important; +} \ No newline at end of file diff --git a/interface/src/components/Picker.tsx b/interface/src/components/Picker.tsx index 19d06478..81f568ed 100644 --- a/interface/src/components/Picker.tsx +++ b/interface/src/components/Picker.tsx @@ -3,6 +3,8 @@ import ColorPicker from 'react-best-gradient-color-picker'; import { useSettingsContext } from '../SettingsContext'; import { motion } from "framer-motion"; +import "./Picker.css"; + export default function Picker() { const { settingsState, setSettingsState, showPicker, setShowPicker } = useSettingsContext(); diff --git a/interface/src/pages/Settings.tsx b/interface/src/pages/Settings.tsx index 46d2b4c4..d0a9f332 100644 --- a/interface/src/pages/Settings.tsx +++ b/interface/src/pages/Settings.tsx @@ -48,11 +48,11 @@ const Settings: React.FC = () => { description: "Customise the overall theme colour of SEQTA Learn.", modifyElement: }, - { + /* { title: "Transparency Effects", description: "Enables transparency effects on certain elements such as blur. (May impact battery life)", modifyElement: switchChange('betterSEQTAPlus', isOn)} /> - }, + }, */ { title: "BetterSEQTA+", description: "Enables BetterSEQTA+ features", diff --git a/main.py b/main.py new file mode 100644 index 00000000..6b57976f --- /dev/null +++ b/main.py @@ -0,0 +1,30 @@ +from svgpathtools import svg2paths, wsvg # you need ``pip install svgpathtools`` +from svgpathtools.path import Path as CombinePath +from pathlib import Path + + +TEST_SVG = Path('test.svg') + + +def main(): + path_list, data_list = svg2paths(str(Path(TEST_SVG))) + + if not 'analysis path': + for idx, cur_path in enumerate(path_list): + wsvg(cur_path, filename=f'result_{idx}.svg', + attributes=[dict(fill="#000000", stroke="none", stroke_width=1)]) + + path_list = [path_list[idx] for idx in (1, 3)] # After analyzing the paths, we find that the paths index 1 and 3 seem to be redundant. + single_path = CombinePath() # combine: 0, 2 together. + for combine_path in path_list: + for curve in combine_path: + single_path.append(curve) + + wsvg(single_path, filename=f'result.svg', + attributes=[dict(fill="#000000", stroke="none", stroke_width=1)], + openinbrowser=True # default is False, + ) + + +if __name__ == '__main__': + main() diff --git a/public/manifest.json b/public/manifest.json index a59b294a..a4bcd65e 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -66,6 +66,10 @@ { "resources": ["client/*"], "matches": ["*://*/*"] + }, + { + "resources": ["resources/*"], + "matches": ["*://*/*"] } ] } diff --git a/public/popup/popup.css b/public/popup/popup.css new file mode 100644 index 00000000..aaa72a99 --- /dev/null +++ b/public/popup/popup.css @@ -0,0 +1,14 @@ +.hide { + opacity: 0; + pointer-events: none; +} + +.outside-container { + margin: 0; + overflow: hidden; + position: absolute; + right: 10px; + top: 80px; + height: 590px; + z-index: 20; +} diff --git a/public/resources/update-video.mp4 b/public/resources/update-video.mp4 new file mode 100644 index 00000000..3efaadf4 Binary files /dev/null and b/public/resources/update-video.mp4 differ diff --git a/result.svg b/result.svg new file mode 100644 index 00000000..e4cafbc1 --- /dev/null +++ b/result.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/SEQTA.js b/src/SEQTA.js index 73b9fece..0a20b8e9 100644 --- a/src/SEQTA.js +++ b/src/SEQTA.js @@ -73,10 +73,16 @@ function OpenWhatsNewPopup() { let imagecont = document.createElement("div"); imagecont.classList.add("whatsnewImgContainer"); - var image = document.createElement("img"); - image.src = chrome.runtime.getURL("icons/betterseqta-dark-icon.png"); - image.classList.add("whatsnewImg"); - imagecont.append(image); + let video = document.createElement("video"); + let source = document.createElement("source"); + source.setAttribute("src", chrome.runtime.getURL("resources/update-video.mp4")); + source.setAttribute("type", "video/mp4"); + video.autoplay = true; + video.muted = true; + video.loop = true; + video.appendChild(source); + video.classList.add("whatsnewImg"); + imagecont.appendChild(video); let textcontainer = document.createElement("div"); textcontainer.classList.add("whatsnewTextContainer"); @@ -91,7 +97,8 @@ function OpenWhatsNewPopup() {
  • Custom backgrounds and themes coming soon!
  • 3.1.2 - New settings menu!

    -
  • Overhauled the settings menu!!!
  • +
  • Overhauled the settings menu
  • +
  • Added custom gradients
  • 3.1.1 - Minor Bug fixes

  • Fixed assessments overlapping
  • Fixed houses not displaying if they aren't a specific color
  • @@ -199,7 +206,7 @@ async function DeleteWhatsNew() { popup.remove(); } -function CreateBackground() { +export function CreateBackground() { // Creating and inserting 3 divs containing the background applied to the pages var bklocation = document.getElementById("container"); var menu = document.getElementById("menu"); @@ -219,7 +226,7 @@ function CreateBackground() { bklocation.insertBefore(bk3, menu); } -function RemoveBackground() { +export function RemoveBackground() { var bk = document.getElementsByClassName("bg"); var bk2 = document.getElementsByClassName("bg2"); var bk3 = document.getElementsByClassName("bg3"); @@ -780,6 +787,12 @@ document.addEventListener( ); function addExtensionSettings() { + let link = document.createElement("link"); + link.href = chrome.runtime.getURL("popup/popup.css"); + link.type = "text/css"; + link.rel = "stylesheet"; + document.getElementsByTagName("html")[0].appendChild(link); + let Settings = stringToHTML( String.raw` @@ -852,7 +865,6 @@ function dragDrop() { // Save position of all menu items let children = parentA.childNodes; - // console.log(children) let listorder = []; for (let i = 0; i < children.length; i++) { @@ -1206,7 +1218,6 @@ function AddBetterSEQTAElements(toggle) { houseelement.innerText = students[index].year + students[index].house; } catch (error) { - console.log(students[index]); houseelement.innerText = students[index].house; } } else { @@ -1264,9 +1275,8 @@ function AddBetterSEQTAElements(toggle) { SendNewsPage(); } }); - } - + appendBackgroundToUI(); addExtensionSettings(); @@ -1611,7 +1621,6 @@ function callHomeTimetable(date, change) { // If items in response: if (serverResponse.payload.items.length > 0) { if (!DayContainer.innerText || change) { - // console.log(serverResponse.payload.items.length); for (let i = 0; i < serverResponse.payload.items.length; i++) { lessonArray.push(serverResponse.payload.items[i]); } @@ -2099,7 +2108,7 @@ chrome.storage.onChanged.addListener(function (changes) { } }); -function GetLessonColours() { +async function GetLessonColours() { let func = fetch(`${location.origin}/seqta/student/load/prefs?`, { method: "POST", headers: { @@ -2148,17 +2157,25 @@ export function CreateCustomShortcutDiv(element) { document.getElementById("shortcuts").append(shortcut); } -export function RemoveCustomShortcutDiv(element) { - // Iterate through each shortcut - const shortcuts = document.querySelectorAll(".shortcut"); - shortcuts.forEach((shortcut) => { - const anchorElement = shortcut.parentElement; // the element is the parent - const textElement = shortcut.querySelector("p"); //

    is a direct child of .shortcut - const title = textElement ? textElement.textContent : ""; - - if (anchorElement.getAttribute("href") === element.url && title === element.name) { - anchorElement.remove(); - } +export function RemoveShortcutDiv(elements) { + elements.forEach((element) => { + const shortcuts = document.querySelectorAll(".shortcut"); + shortcuts.forEach((shortcut) => { + const anchorElement = shortcut.parentElement; // the element is the parent + const textElement = shortcut.querySelector("p"); //

    is a direct child of .shortcut + const title = textElement ? textElement.textContent : ""; + + let shouldRemove = title === element.name; + + // Check href only if element.url exists + if (element.url) { + shouldRemove = shouldRemove && (anchorElement.getAttribute("href") === element.url); + } + + if (shouldRemove) { + anchorElement.remove(); + } + }); }); } @@ -2282,57 +2299,10 @@ function SendHomePage() { changeTimetable(1); }); - function createNewShortcut(link, icon, viewBox, title) { - // Creates the stucture and element information for each seperate shortcut - var shortcut = document.createElement("a"); - shortcut.setAttribute("href", link); - shortcut.setAttribute("target", "_blank"); - var shortcutdiv = document.createElement("div"); - shortcutdiv.classList.add("shortcut"); - - let image = stringToHTML( - ``, - ).firstChild; - image.classList.add("shortcuticondiv"); - var text = document.createElement("p"); - text.textContent = title; - shortcutdiv.append(image); - shortcutdiv.append(text); - shortcut.append(shortcutdiv); - - document.getElementById("shortcuts").append(shortcut); - } // Adds the shortcuts to the shortcut container chrome.storage.local.get(["shortcuts"], function (result) { - var shortcuts = Object.values(result)[0]; - - for (let i = 0; i < shortcuts.length; i++) { - const currentShortcut = shortcuts[i]; - - if (currentShortcut?.enabled) { - const Itemname = currentShortcut?.name; - - const linkDetails = ShortcutLinks?.[Itemname]; - if (linkDetails) { - createNewShortcut( - linkDetails.link, - linkDetails.icon, - linkDetails.viewBox, - Itemname - ); - } else { - console.warn(`No link details found for '${Itemname}'`); - } - } - } - AddCustomShortcutsToPage(); - - // Checks if shortcut container is empty - if (document.getElementById("shortcuts").childElementCount == 0) { - // If there are no shortcuts, hide the container - document.getElementsByClassName("shortcut-container")[0].style.display = - "none"; - } + const shortcuts = Object.values(result)[0]; + addShortcuts(shortcuts); }); // Creates the upcoming container and appends to the home container @@ -2462,7 +2432,6 @@ function SendHomePage() { enableNotificationCollector(); } }); - console.log("Getting assessments"); let activeClassList; GetUpcomingAssessments().then((assessments) => { GetActiveClasses().then((classes) => { @@ -2494,7 +2463,6 @@ function SendHomePage() { } CurrentAssessments.sort(comparedate); - console.log(CurrentAssessments, activeSubjects); CreateUpcomingSection(CurrentAssessments, activeSubjects); @@ -2504,6 +2472,29 @@ function SendHomePage() { }, 8); } +export function addShortcuts(shortcuts) { + for (let i = 0; i < shortcuts.length; i++) { + const currentShortcut = shortcuts[i]; + + if (currentShortcut?.enabled) { + const Itemname = currentShortcut?.name.replace(/\s/g, ""); + + const linkDetails = ShortcutLinks?.[Itemname]; + if (linkDetails) { + createNewShortcut( + linkDetails.link, + linkDetails.icon, + linkDetails.viewBox, + currentShortcut?.name + ); + } else { + console.warn(`No link details found for '${Itemname}'`); + } + } + } + AddCustomShortcutsToPage(); +} + export function enableNotificationCollector() { var xhr3 = new XMLHttpRequest(); xhr3.open("POST", `${location.origin}/seqta/student/heartbeat?`, true); @@ -2544,6 +2535,27 @@ export function disableNotificationCollector() { } } +function createNewShortcut(link, icon, viewBox, title) { + // Creates the stucture and element information for each seperate shortcut + let shortcut = document.createElement("a"); + shortcut.setAttribute("href", link); + shortcut.setAttribute("target", "_blank"); + let shortcutdiv = document.createElement("div"); + shortcutdiv.classList.add("shortcut"); + + let image = stringToHTML( + ``, + ).firstChild; + image.classList.add("shortcuticondiv"); + let text = document.createElement("p"); + text.textContent = title; + shortcutdiv.append(image); + shortcutdiv.append(text); + shortcut.append(shortcutdiv); + + document.getElementById("shortcuts").appendChild(shortcut); +} + function SendNewsPage() { setTimeout(function () { // Sends the html data for the home page diff --git a/src/background.js b/src/background.js index a52889c6..8fec1a66 100644 --- a/src/background.js +++ b/src/background.js @@ -20,16 +20,12 @@ export const openDB = () => { }; export const writeData = async (type, data) => { - console.log("Reading Data"); const db = await openDB(); - console.log("Opened DB"); const tx = db.transaction("backgrounds", "readwrite"); const store = tx.objectStore("backgrounds"); const request = await store.put({ id: "customBackground", type, data }); - console.log("Data written successfully"); - return request.result; }; @@ -37,17 +33,14 @@ export const readData = () => { return new Promise((resolve, reject) => { openDB() .then(db => { - console.log("Database, typeof", typeof db, "Is: ", db); const tx = db.transaction("backgrounds", "readonly"); const store = tx.objectStore("backgrounds"); - console.log("Current store: ", store); // Retrieve the custom background const getRequest = store.get("customBackground"); // Attach success and error event handlers getRequest.onsuccess = function(event) { - console.log("CustomBackground", event.target.result); resolve(event.target.result); }; @@ -99,8 +92,6 @@ const handleAddPermissions = () => { // Main message listener chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - console.log("Message received in background script", request); - switch (request.type) { case "reloadTabs": ReloadSEQTAPages(); @@ -115,7 +106,6 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { break; case "setDefaultStorage": - console.log("Setting default values"); SetStorageValue(DefaultValues); break; @@ -156,9 +146,6 @@ function HandleIntexedDB(request, sendResponse) { function GetNews(sendResponse) { // Gets the current date const date = new Date(); - // Formats the current date used send a request for timetable and notices later - const TodayFormatted = - date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); const from = date.getFullYear() + @@ -166,12 +153,9 @@ function GetNews(sendResponse) { (date.getMonth() + 1) + "-" + (date.getDate() - 1); - console.log(TodayFormatted); - console.log(from); let url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`; - console.log("Fetching news from " + url); fetch(url) .then((result) => result.json()) .then((response) => { @@ -179,7 +163,6 @@ function GetNews(sendResponse) { url += "%00"; GetNews(); } else { - console.log(response); sendResponse({ news: response }); } }); @@ -244,7 +227,7 @@ const DefaultValues = { }, { name: "Education Perfect", - enabled: true, + enabled: false, }, ], customshortcuts: [], @@ -256,9 +239,7 @@ function SetStorageValue(object) { } } -function UpdateCurrentValues(details) { - console.log(details); - +function UpdateCurrentValues() { chrome.storage.local.get(null, function (items) { var CurrentValues = items; @@ -310,9 +291,9 @@ function migrateOldStorage() { // Check for "educationperfect" and convert it to "Education Perfect" if (items.shortcuts && items.shortcuts.length > 0) { for (let shortcut of items.shortcuts) { - if (shortcut.name === "educationperfect") { + if (shortcut.name === "educationperfect" || shortcut.name === "Education Perfect") { shouldUpdate = true; - shortcut.name = "Education Perfect"; // Convert to "Education Perfect" + shortcut.name = "Education Perfect"; } } } @@ -329,6 +310,7 @@ function migrateOldStorage() { chrome.runtime.onInstalled.addListener(function (event) { chrome.storage.local.remove(["justupdated"]); UpdateCurrentValues(); + chrome.storage.local.set({ justupdated: true }); if ( event.reason == "install" ) { chrome.storage.local.set({ justupdated: true }); migrateOldStorage(); diff --git a/src/inject/injected.css b/src/inject/injected.css index 7dce8c8f..4ad04032 100644 --- a/src/inject/injected.css +++ b/src/inject/injected.css @@ -2825,16 +2825,15 @@ body { .whatsnewImgContainer { width: 96%; display: flex; - padding: 2em 0; margin: 0 auto; background: #141414; border-radius: 10px; - margin-bottom: 20px; } .whatsnewImg { - margin: 0 auto; - width: 30%; + margin: 0.5rem 0.5rem; + width: 90%; + border-radius: 1rem; } .whatsnewTextContainer { diff --git a/src/seqta/content/links.json b/src/seqta/content/links.json index bb905aae..3d0c0d21 100644 --- a/src/seqta/content/links.json +++ b/src/seqta/content/links.json @@ -53,5 +53,10 @@ "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": "4.425358206338695 10.109853742009532 167.75614842212613 167.76529918293508", + "icon": "M 41.218842,159.903778 C 32.220757000000006,154.49694799999997 28.320898,146.39567599999998 27.144720000000003,136.691025 C 24.344646000000004,113.587677 21.58695,90.479164 18.767124000000003,67.378227 C 16.473593,48.588874999999994 27.314493000000002,35.167511 46.150131,33.008185999999995 C 69.436394,30.338643999999995 92.70422400000001,27.486617999999993 115.943047,24.432179999999995 C 132.274689,22.285605999999994 146.786301,32.505539 148.981033,48.8368 C 152.235703,73.05532099999999 155.27562,97.309608 157.905701,121.602943 C 159.93542499999998,140.350937 148.836945,152.964386 130.02818299999998,155.067184 C 107.06863399999999,157.634018 84.15766899999998,160.637604 61.23078899999999,163.49321 C 54.302176999999986,164.35621600000002 47.67153899999999,163.743561 41.21884199999999,159.90377800000002 M 90.16155199999999,104.49991600000001 C 90.16451299999999,111.81823700000001 90.16574099999998,119.136559 90.17105099999999,126.45488000000002 C 90.17446899999999,131.15861500000003 93.67040999999999,130.323944 96.55354299999999,130.48759500000003 C 99.573128,130.65899700000003 101.204872,129.66064500000002 101.05652599999999,126.23024700000002 C 100.843948,121.31488000000002 101.00233499999999,116.38347600000002 101.00233499999999,110.84864000000002 C 102.03786499999998,111.51373300000002 102.54609699999999,111.83288600000002 103.04710399999999,112.16302500000002 C 112.86791199999999,118.63465100000002 124.983047,115.43300600000002 129.53965799999997,104.62981400000002 C 131.216278,100.65472400000003 131.70472699999996,95.99940500000002 131.89942899999997,91.61723300000003 C 132.25656099999998,83.57922400000002 129.14271499999998,76.85495800000002 121.90178699999997,72.91539800000002 C 114.83421299999998,69.07015200000002 107.87258899999998,70.25764500000002 101.40912599999997,75.00357800000002 C 100.15898099999997,69.73184200000001 95.94058999999997,71.49647500000002 92.94792199999998,71.84281900000002 C 91.83303799999997,71.97184800000002 90.34555799999998,75.20201900000002 90.28659099999997,77.05806700000002 C 90.00683599999998,85.86446400000003 90.16157499999997,94.68465400000002 90.16155199999997,104.49991600000003 M 47.135135999999974,102.84149200000003 C 47.50462699999997,103.58536500000002 47.86649299999998,104.33315300000002 48.24474299999997,105.07254000000003 C 55.63482299999997,119.51831800000004 75.42236299999998,117.51798200000003 83.29843899999997,107.84790800000003 C 84.09340699999997,106.87186400000003 84.45175199999997,105.03819300000004 84.12631199999997,103.84413100000003 C 83.93784299999997,103.15265700000003 81.92327899999997,102.47944600000004 80.82456999999997,102.60716200000003 C 77.76956899999996,102.96225700000004 74.59602399999997,103.31630700000004 71.77092699999997,104.43350200000003 C 64.22663099999997,107.41690800000003 57.34320099999997,104.57150300000004 57.25969299999997,97.83805100000004 C 65.24485799999997,97.83805100000004 73.23475599999998,97.99984700000003 81.20797699999997,97.70718400000004 C 82.88577299999997,97.64559900000005 85.63535299999997,96.20201100000004 85.96279899999998,94.90748600000003 C 88.05384099999998,86.64054900000004 82.07756799999997,75.75166300000004 74.07153299999997,72.37247500000004 C 64.91693899999997,68.50850700000004 54.85903499999998,71.43896500000004 49.47143599999997,79.54177900000003 C 44.77263999999997,86.60865000000004 45.10080699999997,94.24294300000004 47.13513599999997,102.84149200000003 L 47.135135999999974,102.84149200000003 M 47.035309,102.444016 C 45.100806999999996,94.24294300000001 44.772639999999996,86.60865000000001 49.471436,79.541779 C 54.859035,71.43896500000001 64.916939,68.50850700000001 74.071533,72.37247500000001 C 82.077568,75.75166300000001 88.053841,86.64054900000001 85.962799,94.907486 C 85.63535300000001,96.202011 82.885773,97.645599 81.207977,97.70718400000001 C 73.234756,97.99984700000002 65.244858,97.83805100000001 57.259693,97.83805100000001 C 57.343201,104.571503 64.226631,107.416908 71.770927,104.433502 C 74.596024,103.31630700000001 77.769569,102.96225700000001 80.82457,102.607162 C 81.923279,102.479446 83.937843,103.152657 84.126312,103.844131 C 84.451752,105.038193 84.093407,106.871864 83.298439,107.847908 C 75.422363,117.517982 55.634823,119.51831800000001 48.244743,105.07254 C 47.866493,104.33315300000001 47.504627,103.58536500000001 47.035309,102.444016 M 68.89061,81.05638900000001 C 60.57823199999999,80.556335 57.77417799999999,82.19622000000001 57.24161899999999,88.020081 L 74.64141099999999,88.020081 C 74.94538899999999,87.678658 75.24935899999998,87.337227 75.55333699999998,86.995804 C 73.60168499999999,85.07057200000001 71.65003199999998,83.14534800000001 68.89060999999998,81.05638900000001 L 68.89061,81.05638900000001" } } diff --git a/src/seqta/ui/Animation.js b/src/seqta/ui/Animation.js index c932f407..d7cf9f68 100644 --- a/src/seqta/ui/Animation.js +++ b/src/seqta/ui/Animation.js @@ -4,14 +4,17 @@ * @param {number} [minDuration=1] - The minimum animation duration in seconds. * @param {number} [maxDuration=10] - The maximum animation duration in seconds. */ -export function updateBgDurations(item, minDuration = 1, maxDuration = 10) { +export function updateBgDurations(speed, minDuration = 0.5, maxDuration = 10) { // Class names to look for const bgClasses = ["bg", "bg2", "bg3"]; - - // Reverse the slider direction to align with the animation - const reversedValue = 150 - item.bksliderinput; + let reversedValue; - console.log("reversedValue:", reversedValue); + if (speed.bksliderinput === undefined) { + // Reverse the slider direction to align with the animation + reversedValue = 150 - speed; + } else { + reversedValue = 150 - speed.bksliderinput; + } // Range of possible animation durations const durationRange = maxDuration - minDuration; diff --git a/src/seqta/utils/StorageListener.js b/src/seqta/utils/StorageListener.js index e25c7e79..e04c78c1 100644 --- a/src/seqta/utils/StorageListener.js +++ b/src/seqta/utils/StorageListener.js @@ -1,11 +1,15 @@ /* global chrome */ import { + CreateBackground, CreateCustomShortcutDiv, - RemoveCustomShortcutDiv, + RemoveBackground, + RemoveShortcutDiv, + addShortcuts, disableNotificationCollector, enableNotificationCollector, } from "../../SEQTA.js"; +import { updateBgDurations } from "../ui/Animation.js"; import { updateAllColors } from "../ui/Colors.js"; export default class StorageListener { @@ -18,6 +22,13 @@ export default class StorageListener { this.handleSelectedColorChange(changes.selectedColor.newValue); } + if (changes.shortcuts) { + this.handleShortcutsChange( + changes.shortcuts.oldValue, + changes.shortcuts.newValue + ); + } + if (changes?.customshortcuts?.newValue) { this.handleCustomShortcutsChange( changes.customshortcuts.oldValue, @@ -28,6 +39,19 @@ export default class StorageListener { if (changes.notificationcollector) { this.handleNotificationCollectorChange(changes.notificationcollector); } + + if (changes.bksliderinput) { + updateBgDurations(changes.bksliderinput.newValue); + } + + if (changes.animatedbk !== undefined) { + if (changes.animatedbk.newValue) { + CreateBackground(); + } else { + RemoveBackground(); + document.getElementById("container").style.background = "var(--background-secondary)"; + } + } } handleSelectedColorChange(newColor) { @@ -61,8 +85,41 @@ export default class StorageListener { ); if (removedElement) { - RemoveCustomShortcutDiv(removedElement); + RemoveShortcutDiv(removedElement); } } } + + handleShortcutsChange(oldValue, newValue) { + // Find Added Shortcuts + const addedShortcuts = newValue.filter(newItem => { + const isAdded = oldValue.some(oldItem => { + const match = oldItem.name === newItem.name; + const wasDisabled = !oldItem.enabled; + const isEnabled = newItem.enabled; + return match && wasDisabled && isEnabled; + }); + + return isAdded; + }); + + // Find Removed Shortcuts + const removedShortcuts = newValue.filter(newItem => { + const isRemoved = oldValue.some(oldItem => { + const match = oldItem.name === newItem.name; + const wasEnabled = oldItem.enabled; // Was enabled in the old array + const isDisabled = !newItem.enabled; // Is disabled in the new array + + return match && wasEnabled && isDisabled; + }); + + return isRemoved; + }); + + // Add new shortcuts to the UI + addShortcuts(addedShortcuts); + + // Remove deleted shortcuts from the UI + RemoveShortcutDiv(removedShortcuts); + } } \ No newline at end of file diff --git a/test.svg b/test.svg new file mode 100644 index 00000000..78923e33 --- /dev/null +++ b/test.svg @@ -0,0 +1 @@ + \ No newline at end of file