implementation: make the damn changes on page load

This commit is contained in:
fuwaa 2022-07-10 15:28:03 +08:00
parent 05440f89d5
commit 88f6c1fe8b
No known key found for this signature in database
GPG key ID: 2E4F5DC11DE1D654
5 changed files with 30 additions and 3 deletions

View file

@ -23,6 +23,7 @@ chrome.action.onClicked.addListener((tab) => {
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
chrome.scripting.executeScript({ chrome.scripting.executeScript({
target: { tabId: tabId }, target: { tabId: tabId },
files: ['onload.js'] files: ['initial.js']
}, () => chrome.runtime.lastError); }, () => chrome.runtime.lastError);
}); });

View file

@ -27,3 +27,10 @@ function updateAccents(a1) {
document.querySelectorAll('.Progress-item.rounded-2')[i].style.setProperty('background-color', a1 + "ff", "important"); document.querySelectorAll('.Progress-item.rounded-2')[i].style.setProperty('background-color', a1 + "ff", "important");
} }
} }
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
chrome.scripting.executeScript({
target: { tabId: tabId },
files: ['initial.js']
}, () => chrome.runtime.lastError);
});

View file

@ -467,4 +467,12 @@ chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.set(key); chrome.storage.local.set(key);
console.log("Setup: Configuring " + initialSetting + " >> " + defaultColorScheme[initialSetting]); console.log("Setup: Configuring " + initialSetting + " >> " + defaultColorScheme[initialSetting]);
}); });
}) })
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
chrome.scripting.executeScript({
target: { tabId: tabId },
files: ['initial.js']
}, () => chrome.runtime.lastError);
});

View file

@ -40,7 +40,12 @@
"matches": ["https://*.github.com/*"], "matches": ["https://*.github.com/*"],
"js": ["initial.js"], "js": ["initial.js"],
"css": ["unhide.css"] "css": ["unhide.css"]
},{
"run_at": "document_idle",
"matches": ["https://*.github.com/*"],
"js": ["initial.js"]
} }
], ],
"permissions": ["storage", "scripting"], "permissions": ["storage", "scripting"],

View file

@ -0,0 +1,6 @@
var link = document.createElement('link');
link.href = chrome.extension.getURL('pint-css.css');
link.type = 'text/css';
link.rel = 'stylesheet';
link.media = 'all';
document.getElementsByTagName('head')[0].appendChild(link);