mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
refactor(lint): replace self-equals-this code with arrow functions
This commit is contained in:
@@ -20,10 +20,8 @@ module.exports = {
|
|||||||
plugins: ["react", "@typescript-eslint"],
|
plugins: ["react", "@typescript-eslint"],
|
||||||
rules: {
|
rules: {
|
||||||
// TODO: Remove warn rules when not needed anymore
|
// TODO: Remove warn rules when not needed anymore
|
||||||
"@typescript-eslint/no-this-alias": "warn",
|
|
||||||
"no-self-assign": "off",
|
"no-self-assign": "off",
|
||||||
"@typescript-eslint/no-empty-interface": "off",
|
"@typescript-eslint/no-empty-interface": "off",
|
||||||
"@typescript-eslint/ban-types": "warn",
|
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
react: {
|
react: {
|
||||||
|
|||||||
@@ -444,10 +444,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUnskippedModeInfo(index: number, buttonText: string): SkipNoticeState {
|
getUnskippedModeInfo(index: number, buttonText: string): SkipNoticeState {
|
||||||
const self = this;
|
const maxCountdownTime = () => {
|
||||||
const maxCountdownTime = function() {
|
const sponsorTime = this.segments[index];
|
||||||
const sponsorTime = self.segments[index];
|
const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate));
|
||||||
const duration = Math.round((sponsorTime.segment[1] - self.contentContainer().v.currentTime) * (1 / self.contentContainer().v.playbackRate));
|
|
||||||
|
|
||||||
return Math.max(duration, 4);
|
return Math.max(duration, 4);
|
||||||
};
|
};
|
||||||
|
|||||||
17
src/utils.ts
17
src/utils.ts
@@ -56,16 +56,14 @@ class Utils {
|
|||||||
let permissions = ["declarativeContent"];
|
let permissions = ["declarativeContent"];
|
||||||
if (this.isFirefox()) permissions = [];
|
if (this.isFirefox()) permissions = [];
|
||||||
|
|
||||||
const self = this;
|
|
||||||
|
|
||||||
chrome.permissions.request({
|
chrome.permissions.request({
|
||||||
origins: this.getInvidiousInstancesRegex(),
|
origins: this.getInvidiousInstancesRegex(),
|
||||||
permissions: permissions
|
permissions: permissions
|
||||||
}, async function (granted) {
|
}, async (granted) => {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
self.setupExtraSiteContentScripts();
|
this.setupExtraSiteContentScripts();
|
||||||
} else {
|
} else {
|
||||||
self.removeExtraSiteRegistration();
|
this.removeExtraSiteRegistration();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(granted);
|
callback(granted);
|
||||||
@@ -80,7 +78,6 @@ class Utils {
|
|||||||
* For now, it is just SB.config.invidiousInstances.
|
* For now, it is just SB.config.invidiousInstances.
|
||||||
*/
|
*/
|
||||||
setupExtraSiteContentScripts(): void {
|
setupExtraSiteContentScripts(): void {
|
||||||
const self = this;
|
|
||||||
|
|
||||||
if (this.isFirefox()) {
|
if (this.isFirefox()) {
|
||||||
const firefoxJS = [];
|
const firefoxJS = [];
|
||||||
@@ -107,9 +104,9 @@ class Utils {
|
|||||||
chrome.runtime.sendMessage(registration);
|
chrome.runtime.sendMessage(registration);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"], function() {
|
chrome.declarativeContent.onPageChanged.removeRules(["invidious"], () => {
|
||||||
const conditions = [];
|
const conditions = [];
|
||||||
for (const regex of self.getInvidiousInstancesRegex()) {
|
for (const regex of this.getInvidiousInstancesRegex()) {
|
||||||
conditions.push(new chrome.declarativeContent.PageStateMatcher({
|
conditions.push(new chrome.declarativeContent.PageStateMatcher({
|
||||||
pageUrl: { urlMatches: regex }
|
pageUrl: { urlMatches: regex }
|
||||||
}));
|
}));
|
||||||
@@ -121,8 +118,8 @@ class Utils {
|
|||||||
conditions,
|
conditions,
|
||||||
actions: [new chrome.declarativeContent.RequestContentScript({
|
actions: [new chrome.declarativeContent.RequestContentScript({
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
js: self.js,
|
js: this.js,
|
||||||
css: self.css
|
css: this.css
|
||||||
})]
|
})]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user