-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SimonShiki <[email protected]>
- Loading branch information
1 parent
6f7a811
commit 475cc49
Showing
13 changed files
with
257 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ yarn-error.log | |
|
||
# generated build files | ||
/dist | ||
/extension/scripts/chibi.user.js |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"manifest_version":2,"name":"Chibi","author":"SimonShiki","description":"Load scratch extension everywhere.","version":"5","content_scripts":[{"js":["scripts/content-script.js"],"matches":["https://scratch.mit.edu/projects/*","https://aerfaying.com/Projects/*","https://www.ccw.site/*","https://gitblock.cn/Projects/*","https://world.xiaomawang.com/*","https://cocrea.world/*","https://create.codelab.club/*","https://www.scratch-cn.cn/*","https://www.40code.com/*","https://turbowarp.org/*","https://codingclip.com/*","https://editor.turbowarp.cn/*","https://0832.ink/rc/*","https://code.xueersi.com/scratch3/*","https://code.xueersi.com/home/project/detail?lang=scratch&pid=*&version=3.0&langType=scratch","http://localhost:8601/*"],"run_at":"document_start"}],"web_accessible_resources":["scripts/chibi.user.js"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const scriptElem = document.createElement('script'); | ||
scriptElem.setAttribute('type', 'text/javascript'); | ||
scriptElem.setAttribute('src', chrome.extension.getURL('/scripts/chibi.user.js')); | ||
(document.head || document.documentElement).appendChild(scriptElem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const includeURLs = [ | ||
'https://scratch.mit.edu/projects/*', | ||
'https://aerfaying.com/Projects/*', | ||
'https://www.ccw.site/*', | ||
'https://gitblock.cn/Projects/*', | ||
'https://world.xiaomawang.com/*', | ||
'https://cocrea.world/*', | ||
'https://create.codelab.club/*', | ||
'https://www.scratch-cn.cn/*', | ||
'https://www.40code.com/*', | ||
'https://turbowarp.org/*', | ||
'https://codingclip.com/*', | ||
'https://editor.turbowarp.cn/*', | ||
'https://0832.ink/rc/*', | ||
'https://code.xueersi.com/scratch3/*', | ||
'https://code.xueersi.com/home/project/detail?lang=scratch&pid=*&version=3.0&langType=scratch', | ||
'http://localhost:8601/*' | ||
]; | ||
|
||
module.exports = { | ||
includeURLs | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const { includeURLs } = require('../generate-helper'); | ||
const packageJSON = require('../package.json'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const process = require('node:process'); | ||
const archiver = require('archiver'); | ||
|
||
const env = process.env.BROSWER ?? 'chrome'; | ||
|
||
const manifest = { | ||
manifest_version: 2, | ||
name: packageJSON.displayName, | ||
author: packageJSON.author, | ||
description: packageJSON.description, | ||
version: packageJSON.version, | ||
/* | ||
icons: { | ||
16: 'images/16.png', | ||
32: 'images/32.png', | ||
48: 'images/48.png', | ||
128: 'images/128.png' | ||
}, | ||
*/ | ||
content_scripts: [ | ||
{ | ||
js: [ | ||
'scripts/content-script.js' | ||
], | ||
matches: includeURLs, | ||
run_at: 'document_start' | ||
} | ||
], | ||
web_accessible_resources: [ | ||
'scripts/chibi.user.js' | ||
] | ||
}; | ||
|
||
/** | ||
* @param {String} sourceDir: /some/folder/to/compress | ||
* @param {String} outPath: /path/to/created.zip | ||
* @returns {Promise} | ||
*/ | ||
function zipDirectory (sourceDir, outPath) { | ||
const archive = archiver('zip', { zlib: { level: 9 }}); | ||
const stream = fs.createWriteStream(outPath); | ||
|
||
return new Promise((resolve, reject) => { | ||
archive | ||
.directory(sourceDir, false) | ||
.on('error', err => reject(err)) | ||
.pipe(stream) | ||
; | ||
|
||
stream.on('close', () => resolve()); | ||
archive.finalize(); | ||
}); | ||
} | ||
|
||
(async function pack () { | ||
console.log(`Packing extension for ${env}`); | ||
fs.copyFileSync( | ||
path.resolve(__dirname, '../dist/chibi.user.js'), | ||
path.resolve(__dirname, '../extension/scripts/chibi.user.js') | ||
); | ||
fs.writeFileSync( | ||
path.resolve(__dirname, '../extension/manifest.json'), | ||
JSON.stringify(manifest) | ||
); | ||
zipDirectory( | ||
path.resolve(__dirname, '../extension/'), | ||
path.resolve(__dirname, `../dist/unpacked-extension.zip`) | ||
); | ||
console.log('Done'); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.