mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Added manifest building.
This commit is contained in:
parent
da364b49f0
commit
09a33c4252
11 changed files with 173 additions and 91 deletions
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -18,17 +18,15 @@ jobs:
|
||||||
|
|
||||||
# Create Chrome artifacts
|
# Create Chrome artifacts
|
||||||
- name: Create Chrome artifacts
|
- name: Create Chrome artifacts
|
||||||
run: npm run build
|
run: npm run build:chrome
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Chrome Extension
|
name: Chrome Extension
|
||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
# Create Firefox artifacts
|
# Create Firefox artifacts
|
||||||
- name: Move manifest
|
- name: Create Firefox artifacts
|
||||||
run: mv ./dist/manifest.json ./dist/manifest.json.original
|
run: npm run build:firefox
|
||||||
- name: Combine manifest for Firefox
|
|
||||||
run: jq -s '.[0] * .[1]' ./dist/manifest.json.original ./dist/firefox_manifest-extra.json > manifest.json
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Firefox Extension
|
name: Firefox Extension
|
||||||
|
|
8
manifest/chrome-manifest-extra.json
Normal file
8
manifest/chrome-manifest-extra.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"optional_permissions": [
|
||||||
|
"declarativeContent"
|
||||||
|
],
|
||||||
|
"background": {
|
||||||
|
"persistent": false
|
||||||
|
}
|
||||||
|
}
|
71
manifest/manifest.json
Normal file
71
manifest/manifest.json
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
"name": "__MSG_fullName__",
|
||||||
|
"short_name": "__MSG_Name__",
|
||||||
|
"version": "1.2.5",
|
||||||
|
"default_locale": "en",
|
||||||
|
"description": "__MSG_Description__",
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"run_at": "document_start",
|
||||||
|
"matches": [
|
||||||
|
"https://*.youtube.com/*",
|
||||||
|
"https://www.youtube-nocookie.com/embed/*"
|
||||||
|
],
|
||||||
|
"all_frames": true,
|
||||||
|
"js": [
|
||||||
|
"./js/vendor.js",
|
||||||
|
"./js/content.js"
|
||||||
|
],
|
||||||
|
"css": [
|
||||||
|
"content.css",
|
||||||
|
"./libs/Source+Sans+Pro.css",
|
||||||
|
"popup.css"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"web_accessible_resources": [
|
||||||
|
"icons/LogoSponsorBlocker256px.png",
|
||||||
|
"icons/IconSponsorBlocker256px.png",
|
||||||
|
"icons/PlayerStartIconSponsorBlocker256px.png",
|
||||||
|
"icons/PlayerStopIconSponsorBlocker256px.png",
|
||||||
|
"icons/PlayerUploadIconSponsorBlocker256px.png",
|
||||||
|
"icons/PlayerUploadFailedIconSponsorBlocker256px.png",
|
||||||
|
"icons/upvote.png",
|
||||||
|
"icons/downvote.png",
|
||||||
|
"icons/report.png",
|
||||||
|
"icons/close.png",
|
||||||
|
"icons/PlayerInfoIconSponsorBlocker256px.png",
|
||||||
|
"icons/PlayerDeleteIconSponsorBlocker256px.png",
|
||||||
|
"popup.html"
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"notifications",
|
||||||
|
"https://sponsor.ajay.app/*"
|
||||||
|
],
|
||||||
|
"optional_permissions": [
|
||||||
|
"*://*/*"
|
||||||
|
],
|
||||||
|
"browser_action": {
|
||||||
|
"default_title": "__MSG_Name__",
|
||||||
|
"default_popup": "popup.html"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"scripts":[
|
||||||
|
"./js/vendor.js",
|
||||||
|
"./js/background.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"16": "icons/IconSponsorBlocker16px.png",
|
||||||
|
"32": "icons/IconSponsorBlocker32px.png",
|
||||||
|
"64": "icons/LogoSponsorBlocker64px.png",
|
||||||
|
"128": "icons/LogoSponsorBlocker128px.png",
|
||||||
|
"256": "icons/LogoSponsorBlocker256px.png"
|
||||||
|
},
|
||||||
|
"options_ui": {
|
||||||
|
"page": "options/options.html",
|
||||||
|
"open_in_tab": true
|
||||||
|
},
|
||||||
|
"manifest_version": 2
|
||||||
|
}
|
12
package.json
12
package.json
|
@ -26,10 +26,14 @@
|
||||||
"web-run": "npm run web-run:chrome",
|
"web-run": "npm run web-run:chrome",
|
||||||
"web-run:firefox": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm",
|
"web-run:firefox": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm",
|
||||||
"web-run:chrome": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm -t chromium",
|
"web-run:chrome": "cd dist && web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm -t chromium",
|
||||||
"build:watch": "webpack --config webpack/webpack.dev.js --watch",
|
"build": "npm run build:chrome",
|
||||||
"dev": "concurrently \"npm run web-run\" \"npm run build:watch\"",
|
"build:chrome": "webpack --env.browser=chrome --config webpack/webpack.prod.js",
|
||||||
"dev:firefox": "concurrently \"npm run web-run:firefox\" \"npm run build:watch\"",
|
"build:firefox": "webpack --env.browser=firefox --config webpack/webpack.prod.js",
|
||||||
"build": "webpack --config webpack/webpack.prod.js",
|
"build:watch": "npm run build:chrome:watch",
|
||||||
|
"build:watch:chrome": "webpack --env.browser=chrome --config webpack/webpack.dev.js --watch",
|
||||||
|
"build:watch:firefox": "webpack --env.browser=firefox --config webpack/webpack.dev.js --watch",
|
||||||
|
"dev": "npm run build && concurrently \"npm run web-run\" \"npm run build:watch\"",
|
||||||
|
"dev:firefox": "npm run build:firefox && concurrently \"npm run web-run:firefox\" \"npm run build:watch:firefox\"",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"test": "npx jest"
|
"test": "npx jest"
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="title">
|
<div id="title">
|
||||||
<img src="https://github.com/ajayyy/SponsorBlock/raw/master/icons/LogoSponsorBlocker256px.png" height="80" class="profilepic"/>
|
<img src="../icons/LogoSponsorBlocker256px.png" height="80" class="profilepic"/>
|
||||||
SponsorBlock
|
SponsorBlock
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
{
|
|
||||||
"name": "__MSG_fullName__",
|
|
||||||
"short_name": "__MSG_Name__",
|
|
||||||
"version": "1.2.5",
|
|
||||||
"default_locale": "en",
|
|
||||||
"description": "__MSG_Description__",
|
|
||||||
"content_scripts": [
|
|
||||||
{
|
|
||||||
"run_at": "document_start",
|
|
||||||
"matches": [
|
|
||||||
"https://*.youtube.com/*",
|
|
||||||
"https://www.youtube-nocookie.com/embed/*"
|
|
||||||
],
|
|
||||||
"all_frames": true,
|
|
||||||
"js": [
|
|
||||||
"./js/vendor.js",
|
|
||||||
"./js/content.js"
|
|
||||||
],
|
|
||||||
"css": [
|
|
||||||
"content.css",
|
|
||||||
"./libs/Source+Sans+Pro.css",
|
|
||||||
"popup.css"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"web_accessible_resources": [
|
|
||||||
"icons/LogoSponsorBlocker256px.png",
|
|
||||||
"icons/IconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerStartIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerStopIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerUploadIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerUploadFailedIconSponsorBlocker256px.png",
|
|
||||||
"icons/upvote.png",
|
|
||||||
"icons/downvote.png",
|
|
||||||
"icons/report.png",
|
|
||||||
"icons/close.png",
|
|
||||||
"icons/PlayerInfoIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerDeleteIconSponsorBlocker256px.png",
|
|
||||||
"popup.html"
|
|
||||||
],
|
|
||||||
"permissions": [
|
|
||||||
"storage",
|
|
||||||
"notifications",
|
|
||||||
"https://sponsor.ajay.app/*"
|
|
||||||
],
|
|
||||||
"optional_permissions": [
|
|
||||||
"*://*/*",
|
|
||||||
"declarativeContent"
|
|
||||||
],
|
|
||||||
"browser_action": {
|
|
||||||
"default_title": "__MSG_Name__",
|
|
||||||
"default_popup": "popup.html"
|
|
||||||
},
|
|
||||||
"background": {
|
|
||||||
"scripts":[
|
|
||||||
"./js/vendor.js",
|
|
||||||
"./js/background.js"
|
|
||||||
],
|
|
||||||
"persistent": false
|
|
||||||
},
|
|
||||||
"icons": {
|
|
||||||
"16": "icons/IconSponsorBlocker16px.png",
|
|
||||||
"32": "icons/IconSponsorBlocker32px.png",
|
|
||||||
"64": "icons/LogoSponsorBlocker64px.png",
|
|
||||||
"128": "icons/LogoSponsorBlocker128px.png",
|
|
||||||
"256": "icons/LogoSponsorBlocker256px.png"
|
|
||||||
},
|
|
||||||
"options_ui": {
|
|
||||||
"page": "options/options.html",
|
|
||||||
"open_in_tab": true
|
|
||||||
},
|
|
||||||
"manifest_version": 2
|
|
||||||
}
|
|
|
@ -1,9 +1,10 @@
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const CopyPlugin = require('copy-webpack-plugin');
|
const CopyPlugin = require('copy-webpack-plugin');
|
||||||
|
const BuildManifest = require('./webpack.manifest');
|
||||||
const srcDir = '../src/';
|
const srcDir = '../src/';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = 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'),
|
||||||
|
@ -34,11 +35,14 @@ module.exports = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
// exclude locale files in moment
|
// exclude locale files in moment
|
||||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
||||||
new CopyPlugin([
|
new CopyPlugin([
|
||||||
{ from: '.', to: '../' }
|
{ from: '.', to: '../', ignore: ['manifest.json'] }
|
||||||
],
|
],
|
||||||
{context: 'public' }
|
{context: 'public' }
|
||||||
),
|
),
|
||||||
|
new BuildManifest({
|
||||||
|
browser: env.browser,
|
||||||
|
pretty: env.mode === "production"
|
||||||
|
})
|
||||||
]
|
]
|
||||||
};
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
|
|
||||||
module.exports = merge(common, {
|
module.exports = env => merge(common(env), {
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
mode: 'development'
|
mode: 'development'
|
||||||
});
|
});
|
65
webpack/webpack.manifest.js
Normal file
65
webpack/webpack.manifest.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
const webpack = require("webpack");
|
||||||
|
const path = require('path');
|
||||||
|
const CopyPlugin = require('copy-webpack-plugin');
|
||||||
|
const validateOptions = require('schema-utils');
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const manifest = require("../manifest/manifest.json");
|
||||||
|
const firefoxManifestExtra = require("../manifest/firefox-manifest-extra.json");
|
||||||
|
const chromeManifestExtra = require("../manifest/chrome-manifest-extra.json");
|
||||||
|
|
||||||
|
// schema for options object
|
||||||
|
const schema = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
browser: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
pretty: {
|
||||||
|
type: 'boolean'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class BuildManifest {
|
||||||
|
constructor (options = {}) {
|
||||||
|
validateOptions(schema, options, "Build Manifest Plugin");
|
||||||
|
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(compiler) {
|
||||||
|
const distManifestFile = path.resolve(__dirname, "../dist/manifest.json");
|
||||||
|
|
||||||
|
// Add missing manifest elements
|
||||||
|
if (this.options.browser.toLowerCase() === "firefox") {
|
||||||
|
mergeObjects(manifest, firefoxManifestExtra);
|
||||||
|
} else if (this.options.browser.toLowerCase() === "chrome" || this.options.browser.toLowerCase() === "chromium") {
|
||||||
|
mergeObjects(manifest, chromeManifestExtra);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = JSON.stringify(manifest);
|
||||||
|
if (this.options.pretty) result = JSON.stringify(manifest, null, 2);
|
||||||
|
|
||||||
|
fs.writeFileSync(distManifestFile, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mergeObjects(object1, object2) {
|
||||||
|
for (const key in object2) {
|
||||||
|
if (key in object1) {
|
||||||
|
if (Array.isArray(object1[key])) {
|
||||||
|
object1[key] = object1[key].concat(object2[key]);
|
||||||
|
} else if (typeof object1[key] == 'object') {
|
||||||
|
mergeObjects(object1[key], object2[key]);
|
||||||
|
} else {
|
||||||
|
object1[key] = object2[key];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
object1[key] = object2[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = BuildManifest;
|
|
@ -1,6 +1,11 @@
|
||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
|
|
||||||
module.exports = merge(common, {
|
module.exports = env => {
|
||||||
mode: 'production'
|
let mode = "production";
|
||||||
});
|
env.mode = mode;
|
||||||
|
|
||||||
|
return merge(common(env), {
|
||||||
|
mode
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in a new issue