mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-15 16:07:06 +03:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0f8f5e1d0 | ||
|
|
e948e1e569 | ||
|
|
5289e62d43 | ||
|
|
eda7aac5ef | ||
|
|
d9f4ab0d04 | ||
|
|
2665327729 |
35
.eslintrc.js
35
.eslintrc.js
@@ -1,35 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
es2021: true,
|
|
||||||
node: true,
|
|
||||||
jest: true,
|
|
||||||
jasmine: true,
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:react/recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
],
|
|
||||||
parser: "@typescript-eslint/parser",
|
|
||||||
parserOptions: {
|
|
||||||
ecmaFeatures: {
|
|
||||||
jsx: true,
|
|
||||||
},
|
|
||||||
ecmaVersion: 12,
|
|
||||||
sourceType: "module",
|
|
||||||
},
|
|
||||||
plugins: ["react", "@typescript-eslint"],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/no-unused-vars': 'error',
|
|
||||||
// TODO: Remove warn rules when not needed anymore
|
|
||||||
"no-self-assign": "off",
|
|
||||||
"@typescript-eslint/no-empty-interface": "off",
|
|
||||||
"react/prop-types": [2, { ignore: ['children'] }]
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
react: {
|
|
||||||
version: "detect",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
33
.eslintrc.json
Normal file
33
.eslintrc.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true,
|
||||||
|
"node": true,
|
||||||
|
"jest": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"ecmaVersion": 12,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["react", "@typescript-eslint"],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-unused-vars": "error",
|
||||||
|
"no-self-assign": "off",
|
||||||
|
"@typescript-eslint/no-empty-interface": "off",
|
||||||
|
"react/prop-types": [2, { "ignore": ["children"] }]
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"react": {
|
||||||
|
"version": "detect"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,4 +5,5 @@ module.exports = {
|
|||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.ts$": "ts-jest"
|
"^.+\\.ts$": "ts-jest"
|
||||||
},
|
},
|
||||||
|
"reporters": ["github-actions"]
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "SponsorBlock",
|
||||||
"version": "4.4.4",
|
"version": "4.4.5",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"homepage_url": "https://sponsor.ajay.app",
|
"homepage_url": "https://sponsor.ajay.app",
|
||||||
|
|||||||
6152
package-lock.json
generated
6152
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -3,39 +3,40 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "background.js",
|
"main": "background.js",
|
||||||
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2"
|
"react-dom": "^17.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chrome": "^0.0.180",
|
"@types/chrome": "^0.0.188",
|
||||||
"@types/firefox-webext-browser": "^94.0.1",
|
"@types/firefox-webext-browser": "^94.0.1",
|
||||||
"@types/jest": "^27.4.1",
|
"@types/jest": "^27.5.1",
|
||||||
"@types/react": "^17.0.43",
|
"@types/react": "^17.0.43",
|
||||||
"@types/react-dom": "^17.0.14",
|
"@types/react-dom": "^17.0.14",
|
||||||
"@types/selenium-webdriver": "^4.0.18",
|
"@types/selenium-webdriver": "^4.1.0",
|
||||||
"@types/wicg-mediasession": "^1.1.3",
|
"@types/wicg-mediasession": "^1.1.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
||||||
"@typescript-eslint/parser": "^5.17.0",
|
"@typescript-eslint/parser": "^5.26.0",
|
||||||
"chromedriver": "^100.0.0",
|
"chromedriver": "^101.0.0",
|
||||||
"concurrently": "^7.0.0",
|
"concurrently": "^7.2.1",
|
||||||
"copy-webpack-plugin": "^10.2.4",
|
"copy-webpack-plugin": "^11.0.0",
|
||||||
"eslint": "^8.12.0",
|
"eslint": "^8.16.0",
|
||||||
"eslint-plugin-react": "^7.29.4",
|
"eslint-plugin-react": "^7.30.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^7.2.1",
|
"fork-ts-checker-webpack-plugin": "^7.2.11",
|
||||||
"jest": "^27.5.1",
|
"jest": "^28.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"schema-utils": "^4.0.0",
|
"schema-utils": "^4.0.0",
|
||||||
"selenium-webdriver": "^4.1.1",
|
"selenium-webdriver": "^4.1.2",
|
||||||
"speed-measure-webpack-plugin": "^1.5.0",
|
"speed-measure-webpack-plugin": "^1.5.0",
|
||||||
"ts-jest": "^27.1.4",
|
"ts-jest": "^28.0.3",
|
||||||
"ts-loader": "^9.2.8",
|
"ts-loader": "^9.3.0",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.8.0",
|
||||||
"typescript": "4.6",
|
"typescript": "4.7",
|
||||||
"web-ext": "^6.8.0",
|
"web-ext": "^6.8.0",
|
||||||
"webpack": "^5.64.4",
|
"webpack": "^5.72.1",
|
||||||
"webpack-cli": "^4.9.2",
|
"webpack-cli": "^4.9.2",
|
||||||
"webpack-merge": "^4.2.2"
|
"webpack-merge": "^5.8.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"web-run": "npm run web-run:chrome",
|
"web-run": "npm run web-run:chrome",
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
"lint:fix": "eslint src --fix"
|
"lint:fix": "eslint src --fix"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.20.0"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -480,14 +480,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
|||||||
|
|
||||||
if (!video || video.paused) return;
|
if (!video || video.paused) return;
|
||||||
if (currentTime === undefined || currentTime === null) {
|
if (currentTime === undefined || currentTime === null) {
|
||||||
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
currentTime = getVirtualTime();
|
||||||
(performance.now() - lastKnownVideoTime.preciseTime) / 1000 + lastKnownVideoTime.videoTime : null);
|
|
||||||
if ((lastTimeFromWaitingEvent || !utils.isFirefox())
|
|
||||||
&& !isSafari() && virtualTime && Math.abs(virtualTime - video.currentTime) < 0.6){
|
|
||||||
currentTime = virtualTime;
|
|
||||||
} else {
|
|
||||||
currentTime = video.currentTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lastTimeFromWaitingEvent = null;
|
lastTimeFromWaitingEvent = null;
|
||||||
|
|
||||||
@@ -541,7 +534,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
|||||||
let forcedIncludeNonIntersectingSegments = true;
|
let forcedIncludeNonIntersectingSegments = true;
|
||||||
|
|
||||||
if (incorrectVideoCheck(videoID, currentSkip)) return;
|
if (incorrectVideoCheck(videoID, currentSkip)) return;
|
||||||
forceVideoTime ||= video.currentTime;
|
forceVideoTime ||= Math.max(video.currentTime, getVirtualTime());
|
||||||
|
|
||||||
if (forceVideoTime >= skipTime[0] && forceVideoTime < skipTime[1]) {
|
if (forceVideoTime >= skipTime[0] && forceVideoTime < skipTime[1]) {
|
||||||
skipToTime({
|
skipToTime({
|
||||||
@@ -591,11 +584,23 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
|||||||
logDebug(`Starting timeout to skip ${video.currentTime} to skip at ${skipTime[0]}`);
|
logDebug(`Starting timeout to skip ${video.currentTime} to skip at ${skipTime[0]}`);
|
||||||
|
|
||||||
// Schedule for right before to be more precise than normal timeout
|
// Schedule for right before to be more precise than normal timeout
|
||||||
currentSkipSchedule = setTimeout(skippingFunction, Math.max(0, delayTime - 100));
|
currentSkipSchedule = setTimeout(skippingFunction, Math.max(0, delayTime - 150));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getVirtualTime(): number {
|
||||||
|
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
||||||
|
(performance.now() - lastKnownVideoTime.preciseTime) / 1000 + lastKnownVideoTime.videoTime : null);
|
||||||
|
|
||||||
|
if ((lastTimeFromWaitingEvent || !utils.isFirefox())
|
||||||
|
&& !isSafari() && virtualTime && Math.abs(virtualTime - video.currentTime) < 0.6) {
|
||||||
|
return virtualTime;
|
||||||
|
} else {
|
||||||
|
return video.currentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function inMuteSegment(currentTime: number): boolean {
|
function inMuteSegment(currentTime: number): boolean {
|
||||||
const checkFunction = (segment) => segment.actionType === ActionType.Mute && segment.segment[0] <= currentTime && segment.segment[1] > currentTime;
|
const checkFunction = (segment) => segment.actionType === ActionType.Mute && segment.segment[0] <= currentTime && segment.segment[1] > currentTime;
|
||||||
return sponsorTimes?.some(checkFunction) || sponsorTimesSubmitting.some(checkFunction);
|
return sponsorTimes?.some(checkFunction) || sponsorTimesSubmitting.some(checkFunction);
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ window["SBLogs"] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function logDebug(message: string) {
|
export function logDebug(message: string) {
|
||||||
window["SBLogs"].debug.push(message);
|
window["SBLogs"].debug.push(`[${new Date().toISOString()}] ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logWarn(message: string) {
|
export function logWarn(message: string) {
|
||||||
window["SBLogs"].warn.push(message);
|
window["SBLogs"].warn.push(`[${new Date().toISOString()}] ${message}`);
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const webpack = require("webpack");
|
import webpack from "webpack"
|
||||||
const path = require('path');
|
import path from "path"
|
||||||
const CopyPlugin = require('copy-webpack-plugin');
|
import { fileURLToPath } from "url"
|
||||||
const BuildManifest = require('./webpack.manifest');
|
import CopyPlugin from "copy-webpack-plugin"
|
||||||
const srcDir = '../src/';
|
import BuildManifest from "./webpack.manifest.cjs";
|
||||||
const fs = require("fs");
|
const srcDir = "../src/";
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
import fs from "fs";
|
||||||
|
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
const edgeLanguages = [
|
const edgeLanguages = [
|
||||||
"de",
|
"de",
|
||||||
@@ -24,7 +27,7 @@ const edgeLanguages = [
|
|||||||
"zh_CN"
|
"zh_CN"
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = env => ({
|
export default env => ({
|
||||||
entry: {
|
entry: {
|
||||||
popup: path.join(__dirname, srcDir + 'popup.ts'),
|
popup: path.join(__dirname, srcDir + 'popup.ts'),
|
||||||
background: path.join(__dirname, srcDir + 'background.ts'),
|
background: path.join(__dirname, srcDir + 'background.ts'),
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
import { merge } from "webpack-merge";
|
||||||
const merge = require('webpack-merge');
|
import common from './webpack.common.js';
|
||||||
const common = require('./webpack.common.js');
|
|
||||||
|
|
||||||
module.exports = env => merge(common(env), {
|
export default env => merge(common(env), {
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
mode: 'development'
|
mode: 'development'
|
||||||
});
|
});
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
import { merge } from "webpack-merge";
|
||||||
const merge = require('webpack-merge');
|
import common from './webpack.common.js';
|
||||||
const common = require('./webpack.common.js');
|
|
||||||
|
|
||||||
module.exports = env => {
|
export default env => {
|
||||||
let mode = "production";
|
let mode = "production";
|
||||||
env.mode = mode;
|
env.mode = mode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user