mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Moved registration removal to a util function.
This commit is contained in:
@@ -192,18 +192,7 @@ function invidiousOnClick(checkbox, option) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (isFirefox()) {
|
removeExtraSiteRegistration();
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
message: "unregisterContentScript",
|
|
||||||
id: "invidious"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
chrome.permissions.remove({
|
|
||||||
origins: getInvidiousInstancesRegex()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
popup.js
1
popup.js
@@ -231,7 +231,6 @@ async function runThePopup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//load video times for this video
|
//load video times for this video
|
||||||
console.log( SB.config.sponsorTimes.set)
|
|
||||||
setTimeout(()=> console.log( SB.config.sponsorTimes.set), 200 )
|
setTimeout(()=> console.log( SB.config.sponsorTimes.set), 200 )
|
||||||
let sponsorTimesStorage = SB.config.sponsorTimes.get(currentVideoID);
|
let sponsorTimesStorage = SB.config.sponsorTimes.get(currentVideoID);
|
||||||
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
||||||
|
|||||||
43
utils.js
43
utils.js
@@ -81,21 +81,7 @@ function setupExtraSitePermissions(callback) {
|
|||||||
if (granted) {
|
if (granted) {
|
||||||
setupExtraSiteContentScripts();
|
setupExtraSiteContentScripts();
|
||||||
} else {
|
} else {
|
||||||
if (isFirefox()) {
|
removeExtraSiteRegistration();
|
||||||
if (isBackgroundScript) {
|
|
||||||
if (contentScriptRegistrations[request.id]) {
|
|
||||||
contentScriptRegistrations[request.id].unregister();
|
|
||||||
delete contentScriptRegistrations[request.id];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
message: "unregisterContentScript",
|
|
||||||
id: "invidious"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(granted);
|
callback(granted);
|
||||||
@@ -174,6 +160,33 @@ function setupExtraSiteContentScripts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the permission and content script registration.
|
||||||
|
*/
|
||||||
|
function removeExtraSiteRegistration() {
|
||||||
|
if (isFirefox()) {
|
||||||
|
let id = "invidious";
|
||||||
|
|
||||||
|
if (isBackgroundScript) {
|
||||||
|
if (contentScriptRegistrations[id]) {
|
||||||
|
contentScriptRegistrations[id].unregister();
|
||||||
|
delete contentScriptRegistrations[id];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
message: "unregisterContentScript",
|
||||||
|
id: id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.permissions.remove({
|
||||||
|
origins: getInvidiousInstancesRegex()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function localizeHtmlPage() {
|
function localizeHtmlPage() {
|
||||||
//Localize by replacing __MSG_***__ meta tags
|
//Localize by replacing __MSG_***__ meta tags
|
||||||
var objects = document.getElementsByClassName("sponsorBlockPageBody")[0].children;
|
var objects = document.getElementsByClassName("sponsorBlockPageBody")[0].children;
|
||||||
|
|||||||
Reference in New Issue
Block a user