Converted options page to TypeScript

This commit is contained in:
Ajay Ramachandran
2020-02-03 22:34:43 -05:00
parent 5bb5dae20e
commit b0a23a5c4e
6 changed files with 59 additions and 50 deletions

View File

@@ -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 }
}));