mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Converted options page to TypeScript
This commit is contained in:
13
src/utils.ts
13
src/utils.ts
@@ -42,15 +42,17 @@ class Utils {
|
||||
// Request permission
|
||||
let permissions = ["declarativeContent"];
|
||||
if (this.isFirefox()) permissions = [];
|
||||
|
||||
let self = this;
|
||||
|
||||
chrome.permissions.request({
|
||||
origins: this.getInvidiousInstancesRegex(),
|
||||
permissions: permissions
|
||||
}, async function (granted) {
|
||||
if (granted) {
|
||||
this.setupExtraSiteContentScripts();
|
||||
self.setupExtraSiteContentScripts();
|
||||
} else {
|
||||
this.removeExtraSiteRegistration();
|
||||
self.removeExtraSiteRegistration();
|
||||
}
|
||||
|
||||
callback(granted);
|
||||
@@ -66,7 +68,8 @@ class Utils {
|
||||
*/
|
||||
setupExtraSiteContentScripts() {
|
||||
let js = [
|
||||
"content.js"
|
||||
"./js/vendor.js",
|
||||
"./js/content.js"
|
||||
];
|
||||
let css = [
|
||||
"content.css",
|
||||
@@ -74,6 +77,8 @@ class Utils {
|
||||
"popup.css"
|
||||
];
|
||||
|
||||
let self = this;
|
||||
|
||||
if (this.isFirefox()) {
|
||||
let firefoxJS = [];
|
||||
for (const file of js) {
|
||||
@@ -101,7 +106,7 @@ class Utils {
|
||||
} else {
|
||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"], function() {
|
||||
let conditions = [];
|
||||
for (const regex of this.getInvidiousInstancesRegex()) {
|
||||
for (const regex of self.getInvidiousInstancesRegex()) {
|
||||
conditions.push(new chrome.declarativeContent.PageStateMatcher({
|
||||
pageUrl: { urlMatches: regex }
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user