Skip to content

Commit

Permalink
✨ 添加CAT_userConfig打开用户配置页
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Nov 19, 2022
1 parent 3504d8d commit 025db33
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- test/*
- develop/beta

jobs:
build-deploy:
Expand Down
7 changes: 5 additions & 2 deletions example/userconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// @author You
// @background
// @grant GM_getValue
// @grant CAT_userConfig
// ==/UserScript==

/* ==UserConfig==
Expand Down Expand Up @@ -62,6 +63,8 @@ group2:
type: text
==/UserConfig== */

setInterval(() => {
setInterval(() => {
console.log(GM_getValue("group1.configA"));
}, 5000)
}, 5000)

CAT_userConfig();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scriptcat",
"version": "0.10.1",
"version": "0.11.0-beta",
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
"author": "CodFrm",
"license": "GPLv3",
Expand Down
2 changes: 1 addition & 1 deletion src/app/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ExtVersion = "0.10.0";
export const ExtVersion = "0.11.0-beta";

export const ExtServer =
process.env.NODE_ENV === "development"
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ScriptCat",
"version": "0.10.0",
"version": "0.11.0.1010",
"author": "CodFrm",
"description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.",
"options_ui": {
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/background/gm_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,4 +747,12 @@ export default class GMApi {
GM_unregisterMenuCommand(request: Request) {
GMApi.hook.trigger("unregisterMenu", request.params[0], request);
}

@PermissionVerify.API()
CAT_userConfig(request: Request) {
chrome.tabs.create({
url: `/src/options.html#/?userConfig=${request.scriptId}`,
active: true,
});
}
}
5 changes: 5 additions & 0 deletions src/runtime/content/gm_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,9 @@ export default class GMApi {
GM_unregisterMenuCommand(id: number): void {
this.sendMessage("GM_unregisterMenuCommand", [id]);
}

@GMContext.API()
CAT_userConfig() {
return this.sendMessage("CAT_userConfig", []);
}
}

0 comments on commit 025db33

Please sign in to comment.