mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-17 03:44:25 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into experimental-ajay
This commit is contained in:
38
.github/workflows/ci.yml
vendored
Normal file
38
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Create artifacts
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Initialization
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
- run: npm install
|
||||||
|
- name: Copy configuration
|
||||||
|
run: cp config.js.example config.js
|
||||||
|
|
||||||
|
# Create Chrome artifacts
|
||||||
|
- name: Create Chrome artifacts
|
||||||
|
run: npm run build
|
||||||
|
- uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Chrome Extension
|
||||||
|
path: web-ext-artifacts
|
||||||
|
|
||||||
|
# Create Firefox artifacts
|
||||||
|
- name: Move manifest
|
||||||
|
run: mv manifest.json manifest.json.original
|
||||||
|
- name: Combine manifest for Firefox
|
||||||
|
run: jq -s '.[0] * .[1]' manifest.json.original firefox_manifest-extra.json > manifest.json
|
||||||
|
- name: Create Firefox artifacts
|
||||||
|
run: npm run build
|
||||||
|
- uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Firefox Extension
|
||||||
|
path: web-ext-artifacts
|
||||||
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
config.js
|
config.js
|
||||||
ignored
|
ignored
|
||||||
.idea/
|
.idea/
|
||||||
|
node_modules
|
||||||
|
web-ext-artifacts
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -50,6 +50,16 @@ You can read the API docs [here](https://github.com/ajayyy/SponsorBlockServer#ap
|
|||||||
|
|
||||||
You can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing.
|
You can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing.
|
||||||
|
|
||||||
|
There are also other build scripts available. Install `npm`, then run `npm install` in the repository.
|
||||||
|
|
||||||
|
## Developing with a clean profile
|
||||||
|
|
||||||
|
Run `npm run dev` to run the extension using a clean browser profile with hot reloading [(by default Firefox)](https://hacks.mozilla.org/2019/10/developing-cross-browser-extensions-with-web-ext-3-2-0/). This uses [`web-ext run`](https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#commands).
|
||||||
|
|
||||||
|
## Packing
|
||||||
|
|
||||||
|
Run `npm run build` to generate a packed extension.
|
||||||
|
|
||||||
# Credit
|
# Credit
|
||||||
|
|
||||||
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published.
|
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published.
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "sponsorBlocker@ajay.app",
|
"id": "sponsorBlocker@ajay.app"
|
||||||
"strict_min_version": "57.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7588
package-lock.json
generated
Normal file
7588
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "sponsorblock",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "background.js",
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"web-ext": "^4.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"dev": "web-ext run",
|
||||||
|
"build": "web-ext build --overwrite-dest -i \"*(package-lock.json|README.md|package.json|config.js.example|firefox_manifest-extra.json|manifest.json.original|ignored|crowdin.yml)\""
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/ajayyy/SponsorBlock.git"
|
||||||
|
},
|
||||||
|
"author": "Ajay Ramachandran",
|
||||||
|
"license": "GPL-3.0-only",
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
6
utils.js
6
utils.js
@@ -19,6 +19,9 @@ async function wait(condition, timeout = 5000, check = 100) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getYouTubeVideoID(url) {
|
function getYouTubeVideoID(url) {
|
||||||
|
// For YouTube TV support
|
||||||
|
if(document.URL.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", "");
|
||||||
|
|
||||||
//Attempt to parse url
|
//Attempt to parse url
|
||||||
let urlObject = null;
|
let urlObject = null;
|
||||||
try {
|
try {
|
||||||
@@ -32,7 +35,7 @@ function getYouTubeVideoID(url) {
|
|||||||
if(!["www.youtube.com","www.youtube-nocookie.com"].includes(urlObject.host)) return false;
|
if(!["www.youtube.com","www.youtube-nocookie.com"].includes(urlObject.host)) return false;
|
||||||
|
|
||||||
//Get ID from searchParam
|
//Get ID from searchParam
|
||||||
if ((urlObject.pathname == "/watch" || urlObject.pathname == "/watch/") && urlObject.searchParams.has("v")) {
|
if (urlObject.searchParams.has("v") && ["/watch", "/watch/"].includes(urlObject.pathname) || urlObject.pathname.startsWith("/tv/watch")) {
|
||||||
id = urlObject.searchParams.get("v");
|
id = urlObject.searchParams.get("v");
|
||||||
return id.length == 11 ? id : false;
|
return id.length == 11 ? id : false;
|
||||||
} else if (urlObject.pathname.startsWith("/embed/")) {
|
} else if (urlObject.pathname.startsWith("/embed/")) {
|
||||||
@@ -43,7 +46,6 @@ function getYouTubeVideoID(url) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user