Skip to content

Commit

Permalink
Drop jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
hinaloe committed Aug 17, 2024
1 parent 8e19106 commit 7df6cf1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 43 deletions.
5 changes: 4 additions & 1 deletion entrypoints/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function nyanize() {
walk(document.body);

const observer = new MutationObserver((mutationRecords) => {
for (const record of mutationRecords) {
for (const record of mutationRecords) {
for (const node of record.addedNodes) {
walk(node);
}
Expand Down Expand Up @@ -60,6 +60,9 @@ function walk(node: Node) {
case 3: // Text node
handleText(node as Text);
break;

default:
console.log(node)
}
}

Expand Down
2 changes: 1 addition & 1 deletion entrypoints/popup/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" style="display: none">
<html lang="en" style="opacity: 0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down
44 changes: 29 additions & 15 deletions entrypoints/popup/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import "./style.scss";

import $ from "jquery";

async function init_main() {
let isEnyabled = 1;
//get the current enyabled state and rule list
Expand All @@ -12,42 +10,58 @@ async function init_main() {
isEnyabled = parseInt(data.nyanizeStatus);
}
//make the switch reflect our current state
const nyanizeStatus = document.getElementById(
"nyanizeStatus",
) as HTMLInputElement;
const ultimatenyanizeStatus = document.getElementById(
"ultimatenyanizeStatus",
) as HTMLInputElement;

if (isEnyabled == 1) {
$("#nyanizeStatus").prop("checked", true);
$("#ultimatenyanizeStatus").prop("checked", false);
nyanizeStatus.checked = true;
ultimatenyanizeStatus.checked = false;
} else if (isEnyabled == 2) {
$("#nyanizeStatus").prop("checked", true);
$("#ultimatenyanizeStatus").prop("checked", true);
nyanizeStatus.checked = true;
ultimatenyanizeStatus.checked = true;
} else {
$("#nyanizeStatus").prop("checked", false);
$("#ultimatenyanizeStatus").prop("checked", false);
nyanizeStatus.checked = false;
ultimatenyanizeStatus.checked = false;
}

setupEventHandler();

//show the menu

$("html").fadeIn("slow");
//show the menu with fade-in effect
document.documentElement.style.transition = "opacity 1s";
setTimeout(() => {
document.documentElement.style.opacity = "1";
}, 0);
}

function setupEventHandler() {
const nyanizeStatus = document.getElementById(
"nyanizeStatus",
) as HTMLInputElement;
const ultimatenyanizeStatus = document.getElementById(
"ultimatenyanizeStatus",
) as HTMLInputElement;

//handle enyabling or disabling or the extension
$<HTMLInputElement>("#nyanizeStatus").on("change", function (event) {
nyanizeStatus.addEventListener("change", function (event) {
if (this.checked) {
browser.storage.local.set({
nyanizeStatus: 1,
});
} else {
$("#ultimatenyanizeStatus").prop("checked", false);
ultimatenyanizeStatus.checked = false;
browser.storage.local.set({
nyanizeStatus: 0,
});
}
});

$<HTMLInputElement>("#ultimatenyanizeStatus").on("change", function (event) {
ultimatenyanizeStatus.addEventListener("change", function (event) {
if (this.checked) {
$("#nyanizeStatus").prop("checked", true);
nyanizeStatus.checked = true;
browser.storage.local.set({
nyanizeStatus: 2,
});
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
"postinstall": "wxt prepare"
},
"devDependencies": {
"@types/jquery": "^3.5.30",
"prettier": "^3.3.3",
"sass": "^1.77.8",
"typescript": "^5.5.4",
"wxt": "^0.19.1"
},
"packageManager": "pnpm@9.7.1+sha512.faf344af2d6ca65c4c5c8c2224ea77a81a5e8859cbc4e06b1511ddce2f0151512431dd19e6aff31f2c6a8f5f2aced9bd2273e1fed7dd4de1868984059d2c4247",
"dependencies": {
"bootstrap": "^5.3.3",
"jquery": "^3.7.1"
"bootstrap": "^5.3.3"
}
}
23 changes: 0 additions & 23 deletions pnpm-lock.yaml

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

0 comments on commit 7df6cf1

Please sign in to comment.