Skip to content

Commit

Permalink
Merge pull request #69 from SethBurkart123/firefox->chrome
Browse files Browse the repository at this point in the history
Merge fixes in Firefox branch to main branch (testing in chrome worked)
  • Loading branch information
Crazypersonalph authored Dec 4, 2023
2 parents f48fc72 + 1bae739 commit 63fda52
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 30 deletions.
1 change: 1 addition & 0 deletions interface/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

4 changes: 3 additions & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
},
"dependencies": {
"@types/chrome": "^0.0.246",
"@types/webextension-polyfill": "^0.10.7",
"framer-motion": "^10.16.4",
"react": "^18.2.0",
"react-best-gradient-color-picker": "2.2.24",
"react-dom": "^18.2.0",
"react-router-dom": "latest",
"tinycolor2": "^1.6.0"
"tinycolor2": "^1.6.0",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
14 changes: 14 additions & 0 deletions interface/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions interface/src/hooks/ThemeManagment.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import browser from 'webextension-polyfill'
interface ThemeList {
themes: string[];
selectedTheme: string;
}

export const downloadTheme = async (themeName: string, themeURL: string) => {
// send message to the background script
const response = await chrome.runtime.sendMessage({
const response = await browser.runtime.sendMessage({
type: 'currentTab',
info: 'DownloadTheme',
body: {
Expand All @@ -19,7 +20,7 @@ export const downloadTheme = async (themeName: string, themeURL: string) => {

export const setTheme = async (themeName: string, themeURL: string) => {
// send message to the background script
const response = await chrome.runtime.sendMessage({
const response = await browser.runtime.sendMessage({
type: 'currentTab',
info: 'SetTheme',
body: {
Expand All @@ -33,7 +34,7 @@ export const setTheme = async (themeName: string, themeURL: string) => {

export const listThemes = async () => {
// send message to the background script
const response: ThemeList = await chrome.runtime.sendMessage({
const response: ThemeList = await browser.runtime.sendMessage({
type: 'currentTab',
info: 'ListThemes'
});
Expand All @@ -45,14 +46,14 @@ export const listThemes = async () => {
}

export const disableTheme = async () => {
await chrome.runtime.sendMessage({
await browser.runtime.sendMessage({
type: 'currentTab',
info: 'DisableTheme',
});
};

export const deleteTheme = async (themeName: string) => {
await chrome.runtime.sendMessage({
await browser.runtime.sendMessage({
type: 'currentTab',
info: 'DeleteTheme',
body: {
Expand Down
13 changes: 7 additions & 6 deletions interface/src/hooks/settingsState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*global chrome*/
import browser from 'webextension-polyfill'
import { useEffect, useMemo } from "react";
import { SettingsProps } from "../types/SettingsProps";
import { MainConfig, SettingsState } from "../types/AppProps";
Expand All @@ -12,7 +12,8 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
RanOnce = true;

// get the current settings state
chrome.storage.local.get(function(result: MainConfig) {
// @ts-expect-error idk js/ts wizardry
browser.storage.local.get().then().then(function(result: MainConfig) {
setSettingsState({
notificationCollector: result.notificationcollector,
lessonAlerts: result.lessonalert,
Expand Down Expand Up @@ -43,7 +44,7 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
"transparencyEffects": "transparencyEffects"
}), []);

const storageChangeListener = (changes: chrome.storage.StorageChange) => {
const storageChangeListener = (changes: browser.Storage.StorageChange) => {
for (const [key, { newValue }] of Object.entries(changes)) {
if (key === "DarkMode") {
if (key === "DarkMode" && newValue) {
Expand All @@ -66,14 +67,14 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
};

useEffect(() => {
chrome.storage.onChanged.addListener(storageChangeListener);
browser.storage.onChanged.addListener(storageChangeListener);
return () => {
chrome.storage.onChanged.removeListener(storageChangeListener);
browser.storage.onChanged.removeListener(storageChangeListener);
};
});

const setStorage = (key: keyof MainConfig, value: any) => {
chrome.storage.local.set({ [key]: value });
browser.storage.local.set({ [key]: value });
}

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion interface/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { HashRouter, Routes, Route } from 'react-router-dom';
import './index.css';
import { SettingsContextProvider } from './SettingsContext.js';
import SettingsPage from './SettingsPage.js';
const fontURL = chrome.runtime.getURL("fonts/IconFamily.woff");
import browser from 'webextension-polyfill'
const fontURL = browser.runtime.getURL("fonts/IconFamily.woff");

const style = document.createElement("style");
style.setAttribute("type", "text/css");
Expand Down
4 changes: 3 additions & 1 deletion interface/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PickerSwatch from '../components/PickerSwatch';
import { SettingsList } from '../types/SettingsProps';
import { useSettingsContext } from '../SettingsContext';

import browser from 'webextension-polyfill'

const Settings: React.FC = () => {
const { settingsState, setSettingsState } = useSettingsContext();

Expand Down Expand Up @@ -51,7 +53,7 @@ const Settings: React.FC = () => {
{
title: "Edit Sidebar Layout",
description: "Customise the sidebar layout.",
modifyElement: <button onClick={() => chrome.runtime.sendMessage({ type: 'currentTab', info: 'EditSidebar' })} className='px-4 py-1 text-[0.75rem] dark:bg-[#38373D] bg-[#DDDDDD] dark:text-white rounded-md'>Edit</button>
modifyElement: <button onClick={() => browser.runtime.sendMessage({ type: 'currentTab', info: 'EditSidebar' })} className='px-4 py-1 text-[0.75rem] dark:bg-[#38373D] bg-[#DDDDDD] dark:text-white rounded-md'>Edit</button>
},
{
title: "Transparency Effects",
Expand Down
8 changes: 3 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/backgrounds/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
object-fit: cover;
}
</style>
<script type="application/javascript" src="/browser-polyfill.js"></script>
</head>
<body>
<!-- Container for the media -->
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@
"matches": ["*://*/*"]
}
]
}
}
14 changes: 10 additions & 4 deletions src/SEQTA.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-inner-declarations */
import browser from 'webextension-polyfill'
import browser from 'webextension-polyfill';
import { animate, spring, stagger } from 'motion';
import Color from 'color';
import Sortable, { AutoScroll } from 'sortablejs/modular/sortable.core.esm.js';
Expand Down Expand Up @@ -220,7 +220,7 @@ function OpenWhatsNewPopup() {
<g><path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="currentColor" /></g>
</svg>
</a>
<a href="https://chrome.google.com/webstore/detail/betterseqta%2B/afdgaoaclhkhemfkkkonemoapeinchel" target="_blank" style="background: none !important; margin: 0 5px; padding:0;">
<a href="https://browser.google.com/webstore/detail/betterseqta%2B/afdgaoaclhkhemfkkkonemoapeinchel" target="_blank" style="background: none !important; margin: 0 5px; padding:0;">
<svg style="width:25px;height:25px" viewBox="0 0 24 24">
<path fill="currentColor" d="M12,20L15.46,14H15.45C15.79,13.4 16,12.73 16,12C16,10.8 15.46,9.73 14.62,9H19.41C19.79,9.93 20,10.94 20,12A8,8 0 0,1 12,20M4,12C4,10.54 4.39,9.18 5.07,8L8.54,14H8.55C9.24,15.19 10.5,16 12,16C12.45,16 12.88,15.91 13.29,15.77L10.89,19.91C7,19.37 4,16.04 4,12M15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9A3,3 0 0,1 15,12M12,4C14.96,4 17.54,5.61 18.92,8H12C10.06,8 8.45,9.38 8.08,11.21L5.7,7.08C7.16,5.21 9.44,4 12,4M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</svg>
Expand Down Expand Up @@ -287,6 +287,7 @@ async function finishLoad() {
console.log(err);
}


const result = browser.storage.local.get(['justupdated']);
function open (result) {
if (result.justupdated && !document.getElementById('whatsnewbk')) {
Expand All @@ -310,6 +311,10 @@ async function DeleteWhatsNew() {
}

export function CreateBackground() {
var bkCheck = document.getElementsByClassName('bg');
if (bkCheck.length !== 0) {
return;
}
// Creating and inserting 3 divs containing the background applied to the pages
var bklocation = document.getElementById('container');
var menu = document.getElementById('menu');
Expand All @@ -335,10 +340,10 @@ export function RemoveBackground() {
var bk3 = document.getElementsByClassName('bg3');

if (bk.length == 0 || bk2.length == 0 || bk3.length == 0) return;

bk[0].remove();
bk2[0].remove();
bk3[0].remove();
console.log('it deleted???')
}

export function waitForElm(selector) {
Expand Down Expand Up @@ -371,7 +376,6 @@ async function RunColourCheck(element) {
element.contentDocument.documentElement.childNodes[1].style.color = 'white';
}
}

export function GetCSSElement (file) {
const cssFile = browser.runtime.getURL(file)
const fileref = document.createElement('link')
Expand Down Expand Up @@ -2202,6 +2206,7 @@ export function RemoveShortcutDiv(elements) {
function AddCustomShortcutsToPage() {
const result = browser.storage.local.get(['customshortcuts'])
function open (result) {

var customshortcuts = Object.values(result)[0];
if (customshortcuts.length > 0) {
document.getElementsByClassName('shortcut-container')[0].style.display =
Expand Down Expand Up @@ -2324,6 +2329,7 @@ function SendHomePage() {
// Adds the shortcuts to the shortcut container
const result = browser.storage.local.get(['shortcuts'])
function open (result) {

const shortcuts = Object.values(result)[0];
addShortcuts(shortcuts);
}
Expand Down
1 change: 1 addition & 0 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import browser from 'webextension-polyfill'
import { onError } from './seqta/utils/onError.js';
export const openDB = () => {
Expand Down
12 changes: 6 additions & 6 deletions src/css/injected.scss
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ td.colourBar {
/* Provides space for the icon */
}
#toolbar span:has(.search)::before {
content: "";
content: "\eca5";
/* Unicode for the search icon */
position: absolute;
left: 8px;
Expand Down Expand Up @@ -1879,7 +1879,7 @@ body {
align-items: center;
}
[data-label="inbox"] > .LabelList__name___-CHgq::before {
content: "";
content: "\eb70";
/* Unicode for the search icon */
color: currentColor;
font-size: 16px;
Expand All @@ -1889,7 +1889,7 @@ body {
pointer-events: none;
}
[data-label="outbox"] > .LabelList__name___-CHgq::before {
content: "";
content: "\eca6";
/* Unicode for the search icon */
color: currentColor;
font-size: 16px;
Expand All @@ -1899,7 +1899,7 @@ body {
pointer-events: none;
}
[data-label="starred"] > .LabelList__name___-CHgq::before {
content: "";
content: "\ece8";
color: currentColor;
font-size: 16px;
margin-right: 8px;
Expand All @@ -1908,7 +1908,7 @@ body {
pointer-events: none;
}
[data-label="trash"] > .LabelList__name___-CHgq::before {
content: "";
content: "\ed2c";
/* Unicode for the search icon */
color: currentColor;
font-size: 16px;
Expand Down Expand Up @@ -2739,7 +2739,7 @@ body:has(.outside-container:not(.hide)) #AddedSettings.tooltip:hover > .tooltipt
cursor: pointer;
}
#whatsnewclosebutton::before {
content: "";
content: "\ed8a";
color: currentColor;
font-size: 24px;
font-family: "IconFamily";
Expand Down

0 comments on commit 63fda52

Please sign in to comment.