Skip to content

Commit

Permalink
Update: Auto reload with icon click
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayao0819 committed Oct 13, 2023
1 parent 4c0f29c commit 0167796
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ chrome.runtime.onInstalled.addListener(() => {
chrome.action.setBadgeText({ text: "ON" });
});

chrome.action.onClicked.addListener(async () => {
chrome.action.onClicked.addListener(async (tab) => {
const isEnable = await getIsEnabled();
storage.set({ enabled: !isEnable });
chrome.action.setBadgeText({ text: isEnable ? "OFF" : "ON" });
console.log("enabled:", !isEnable);

if (tab.id === undefined) return;
chrome.tabs.sendMessage(tab.id, "reload").catch((e) => console.error(e));
});
6 changes: 6 additions & 0 deletions src/content_kyomu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ import Kyomu from "./Kyomu";
import runIfEnabled from "./utils/runIfEnabled";

window.addEventListener("load", async () => await runIfEnabled(Kyomu.EnableRainbow));

chrome.runtime.onMessage.addListener((message) => {
if (message === "reload") {
location.reload();
}
});
4 changes: 4 additions & 0 deletions src/content_moodle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import runIfEnabled from "./utils/runIfEnabled";

window.addEventListener("load", async () => await runIfEnabled(Moodle.EnableRainbow));

chrome.runtime.onMessage.addListener((message) => {
if (message === "reload") location.reload();
});

// あとでリロード無しでゲーミングモード解除を実装する
/*
chrome.action.onClicked.addListener(async () => {
Expand Down
6 changes: 6 additions & 0 deletions src/content_sso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ import SSO from "./SSO";
import runIfEnabled from "./utils/runIfEnabled";

window.addEventListener("load", async () => await runIfEnabled(SSO.EnableRainbow));

chrome.runtime.onMessage.addListener((message) => {
if (message === "reload") {
location.reload();
}
});

0 comments on commit 0167796

Please sign in to comment.