mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
refactor: remove more unused variables
This commit is contained in:
@@ -276,7 +276,7 @@ function decodeStoredItem<T>(id: string, data: T): T | SBMap<string, SponsorTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
function configProxy(): any {
|
function configProxy(): any {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes) => {
|
||||||
for (const key in changes) {
|
for (const key in changes) {
|
||||||
Config.localConfig[key] = decodeStoredItem(key, changes[key].newValue);
|
Config.localConfig[key] = decodeStoredItem(key, changes[key].newValue);
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ function configProxy(): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchConfig(): Promise<void> {
|
function fetchConfig(): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
chrome.storage.sync.get(null, function(items) {
|
chrome.storage.sync.get(null, function(items) {
|
||||||
Config.localConfig = <SBConfig> <unknown> items; // Data is ready
|
Config.localConfig = <SBConfig> <unknown> items; // Data is ready
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
|
|
||||||
import { SponsorTime, CategorySkipOption, CategorySelection, VideoID, SponsorHideType, FetchResponse } from "./types";
|
import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse } from "./types";
|
||||||
|
|
||||||
import { ContentContainer } from "./types";
|
import { ContentContainer } from "./types";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
@@ -740,7 +740,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
|||||||
* Get the video info for the current tab from YouTube
|
* Get the video info for the current tab from YouTube
|
||||||
*/
|
*/
|
||||||
function getVideoInfo() {
|
function getVideoInfo() {
|
||||||
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp, error) {
|
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp) {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1];
|
const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1];
|
||||||
if (!decodedData) {
|
if (!decodedData) {
|
||||||
@@ -1051,7 +1051,7 @@ function createButton(baseID, title, callback, imageName, isDraggable=false): bo
|
|||||||
newButton.classList.add("playerButton");
|
newButton.classList.add("playerButton");
|
||||||
newButton.classList.add("ytp-button");
|
newButton.classList.add("ytp-button");
|
||||||
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
||||||
newButton.addEventListener("click", (event: Event) => {
|
newButton.addEventListener("click", () => {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1435,8 +1435,6 @@ function submitSponsorTimes() {
|
|||||||
//it can't update to this info yet
|
//it can't update to this info yet
|
||||||
closeInfoMenu();
|
closeInfoMenu();
|
||||||
|
|
||||||
const currentVideoID = sponsorVideoID;
|
|
||||||
|
|
||||||
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
if (sponsorTimesSubmitting !== undefined && sponsorTimesSubmitting.length > 0) {
|
||||||
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
submissionNotice = new SubmissionNotice(skipNoticeContentContainer, sendSubmitMessage);
|
||||||
}
|
}
|
||||||
@@ -1583,7 +1581,7 @@ function sendRequestToCustomServer(type, fullAddress, callback) {
|
|||||||
callback(xmlhttp, false);
|
callback(xmlhttp, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
xmlhttp.onerror = function(ev) {
|
xmlhttp.onerror = function() {
|
||||||
callback(xmlhttp, true);
|
callback(xmlhttp, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Config from "./config";
|
|||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
|
|
||||||
// Make the config public for debugging purposes
|
// Make the config public for debugging purposes
|
||||||
(<any> window).SB = Config;
|
window.SB = Config;
|
||||||
|
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
import CategoryChooser from "./render/CategoryChooser";
|
import CategoryChooser from "./render/CategoryChooser";
|
||||||
@@ -107,7 +107,7 @@ async function init() {
|
|||||||
|
|
||||||
// Permission needed on Firefox
|
// Permission needed on Firefox
|
||||||
if (utils.isFirefox()) {
|
if (utils.isFirefox()) {
|
||||||
const permissionSuccess = await new Promise((resolve, reject) => {
|
const permissionSuccess = await new Promise((resolve) => {
|
||||||
chrome.permissions.request({
|
chrome.permissions.request({
|
||||||
origins: [textChangeInput.value + "/"],
|
origins: [textChangeInput.value + "/"],
|
||||||
permissions: []
|
permissions: []
|
||||||
@@ -202,7 +202,7 @@ async function init() {
|
|||||||
*
|
*
|
||||||
* @param {String} element
|
* @param {String} element
|
||||||
*/
|
*/
|
||||||
function optionsConfigUpdateListener(changes) {
|
function optionsConfigUpdateListener() {
|
||||||
const optionsContainer = document.getElementById("options");
|
const optionsContainer = document.getElementById("options");
|
||||||
const optionsElements = optionsContainer.querySelectorAll("*");
|
const optionsElements = optionsContainer.querySelectorAll("*");
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ function invidiousInstanceAddInit(element: HTMLElement, option: string) {
|
|||||||
const button = element.querySelector(".trigger-button");
|
const button = element.querySelector(".trigger-button");
|
||||||
|
|
||||||
const setButton = element.querySelector(".text-change-set");
|
const setButton = element.querySelector(".text-change-set");
|
||||||
setButton.addEventListener("click", async function(e) {
|
setButton.addEventListener("click", async function() {
|
||||||
if (textBox.value == "" || textBox.value.includes("/") || textBox.value.includes("http")) {
|
if (textBox.value == "" || textBox.value.includes("/") || textBox.value.includes("http")) {
|
||||||
alert(chrome.i18n.getMessage("addInvidiousInstanceError"));
|
alert(chrome.i18n.getMessage("addInvidiousInstanceError"));
|
||||||
} else {
|
} else {
|
||||||
@@ -269,7 +269,7 @@ function invidiousInstanceAddInit(element: HTMLElement, option: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const resetButton = element.querySelector(".invidious-instance-reset");
|
const resetButton = element.querySelector(".invidious-instance-reset");
|
||||||
resetButton.addEventListener("click", function(e) {
|
resetButton.addEventListener("click", function() {
|
||||||
if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) {
|
if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) {
|
||||||
// Set to a clone of the default
|
// Set to a clone of the default
|
||||||
Config.config[option] = Config.defaults[option].slice(0);
|
Config.config[option] = Config.defaults[option].slice(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user