Skip to content

Commit

Permalink
feat: add a extension
Browse files Browse the repository at this point in the history
  • Loading branch information
biuuu committed Apr 29, 2022
1 parent 1b0fa68 commit 72f2399
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extension/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extName": {
"message": "ShinyColors async app script",
"description": "Extension name"
},
"desc": {
"message": "Make third-party userscripts load more stable by setting the async attribute on the game's app script",
"description": "Extension description"
}
}
10 changes: 10 additions & 0 deletions extension/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extName": {
"message": "闪耀色彩异步脚本",
"description": "扩展名"
},
"desc": {
"message": "通过给游戏的app脚本设置async属性使第三方用户脚本更稳定的加载",
"description": "Extension description"
}
}
22 changes: 22 additions & 0 deletions extension/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const mutationCallback = (mutationsList) => {
for (let mutation of mutationsList) {
const addedNodes = mutation.addedNodes
addedNodes.forEach(node => {
if ('SCRIPT' === node.tagName) {
if (node.src.includes('shinycolors.enza.fun/app')) {
node.async = true
observer.disconnect()
}
}
})
}
}

const obConfig = {
subtree: true,
childList: true
}

const targetNode = document
const observer = new MutationObserver(mutationCallback)
observer.observe(targetNode, obConfig)
Binary file added extension/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "__MSG_extName__",
"description": "__MSG_desc__",
"version": "1.0",
"manifest_version": 3,
"default_locale": "zh_CN",
"content_scripts": [
{
"matches": ["*://shinycolors.enza.fun/*"],
"run_at": "document_start",
"js": ["content-script.js"]
}
],
"icons": {
"128": "/icon.png"
}
}

4 comments on commit 72f2399

@biuuu
Copy link
Owner Author

@biuuu biuuu commented on 72f2399 May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snowyivu @Damillora
https://chrome.google.com/webstore/detail/caafhkjcgpbinkgnghkojaoipgdkbcbc
I've released a chrome extension that can fix the problem that userscript sometimes doesn't load successfully.
Here's the code: https://github.com/biuuu/ShinyColors/tree/master/extension

@snowyivu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

群主biuuu !!
Thank you very much! I will repay you with a gift - who is your favorite idol?

@biuuu
Copy link
Owner Author

@biuuu biuuu commented on 72f2399 May 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

群主biuuu !! Thank you very much! I will repay you with a gift - who is your favorite idol?

Thank you! My favorite idol is Mano.

@snowyivu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.