Skip to content

Commit 1ee42ad

Browse files
committed
🔥 废弃proxy功能 #60
1 parent d9bce47 commit 1ee42ad

File tree

9 files changed

+78
-114
lines changed

9 files changed

+78
-114
lines changed

build/scriptcat/manifest.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "ScriptCat",
4-
"version": "0.9.0",
4+
"version": "0.9.1",
55
"description": "脚本猫,一个用户脚本的框架,可编写脚本每天帮你自动处理事务.",
66
"background": {
77
"page": "background.html"
@@ -31,13 +31,11 @@
3131
],
3232
"permissions": [
3333
"tabs",
34-
"proxy",
3534
"cookies",
3635
"storage",
3736
"debugger",
3837
"downloads",
3938
"webRequest",
40-
"management",
4139
"background",
4240
"<all_urls>",
4341
"contextMenus",

package-lock.json

Lines changed: 57 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"scripts": {
66
"lint": "eslint --ext .js,.ts,.tsx tests/ src/",
@@ -25,7 +25,7 @@
2525
"dexie": "^3.2.0",
2626
"file-saver": "^2.0.5",
2727
"jszip": "^3.7.1",
28-
"log4js": "^6.4.1",
28+
"log4js": "^6.4.5",
2929
"monaco-editor": "^0.22.0",
3030
"reflect-metadata": "^0.1.13",
3131
"sortablejs": "^1.14.0",

src/apps/app.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { SystemConfig } from '@App/pkg/config';
21
import { ICache } from '@App/pkg/storage/cache/cache';
32
import { Logger } from './logger/logger';
43

src/apps/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const ExtVersion = '0.9.0';
1+
export const ExtVersion = '0.9.1';
22

33
export const Server = process.env.NODE_ENV == 'production' ? 'https://sc.icodef.com/' : 'http://localhost:8080/';
44

src/background.ts

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ user.listenEvent();
5252
tools.listenEvent();
5353

5454
grant.listenScriptGrant();
55-
window.addEventListener('message', (event) => {
55+
56+
// 监听日志
57+
window.addEventListener('message', (event: MessageEvent<{ action: string; data: any }>) => {
5658
if (event.data.action != Logger) {
5759
return;
5860
}
@@ -64,7 +66,7 @@ const timer = setInterval(() => {
6466
sandbox.postMessage({ action: 'load' }, '*');
6567
}, 1000);
6668
window.addEventListener('message', sandboxLoad);
67-
function sandboxLoad(event: MessageEvent) {
69+
function sandboxLoad(event: MessageEvent<{ action: string }>) {
6870
clearInterval(timer);
6971
window.removeEventListener('message', sandboxLoad);
7072
if (event.origin != 'null' && event.origin != App.ExtensionId) {
@@ -118,28 +120,29 @@ setInterval(() => {
118120

119121
get(Server + 'api/v1/system/version', (str) => {
120122
chrome.storage.local.get(['oldNotice'], (items) => {
121-
const resp = JSON.parse(str);
123+
const resp = <{ data: { notice: string; version: string } }>JSON.parse(str);
122124
if (resp.data.notice !== items['oldNotice']) {
123-
chrome.storage.local.set({
125+
void chrome.storage.local.set({
124126
notice: resp.data.notice,
125127
});
126128
}
127-
chrome.storage.local.set({
129+
void chrome.storage.local.set({
128130
version: resp.data.version,
129131
});
130132
});
131133
});
134+
132135
// 半小时同步一次数据和检查更新
133136
setInterval(() => {
134137
get(Server + 'api/v1/system/version', (str) => {
135138
chrome.storage.local.get(['oldNotice'], (items) => {
136-
const resp = JSON.parse(str);
139+
const resp = <{ data: { notice: string; version: string } }>JSON.parse(str);
137140
if (resp.data.notice !== items['oldNotice']) {
138-
chrome.storage.local.set({
141+
void chrome.storage.local.set({
139142
notice: resp.data.notice,
140143
});
141144
}
142-
chrome.storage.local.set({
145+
void chrome.storage.local.set({
143146
version: resp.data.version,
144147
});
145148
});
@@ -152,42 +155,9 @@ setInterval(() => {
152155
if (process.env.NODE_ENV == 'production') {
153156
chrome.runtime.onInstalled.addListener((details) => {
154157
if (details.reason == 'install') {
155-
chrome.tabs.create({ url: 'https://docs.scriptcat.org/' });
158+
void chrome.tabs.create({ url: 'https://docs.scriptcat.org/' });
156159
} else if (details.reason == 'update') {
157-
chrome.tabs.create({ url: 'https://docs.scriptcat.org/change/' });
160+
void chrome.tabs.create({ url: 'https://docs.scriptcat.org/change/' });
158161
}
159162
});
160163
}
161-
162-
chrome.management.onEnabled.addListener((info) => {
163-
for (const [, value] of info.permissions.entries()) {
164-
if (value == 'proxy') {
165-
InfoNotification(
166-
'检测到扩展proxy权限冲突',
167-
'检测到扩展"' + info.name + '"与ScriptCat冲突,可能会导致无法正常使用ScriptCat'
168-
);
169-
break;
170-
}
171-
}
172-
});
173-
174-
chrome.management.getAll((items) => {
175-
let text = '';
176-
for (const item of items) {
177-
if (item.id == chrome.runtime.id) {
178-
continue;
179-
}
180-
for (const [, value] of item.permissions.entries()) {
181-
if (value == 'proxy') {
182-
text += item.name + ';';
183-
break;
184-
}
185-
}
186-
}
187-
if (text !== '') {
188-
InfoNotification(
189-
'检测到扩展proxy权限冲突',
190-
'检测到扩展"' + text + '"与ScriptCat冲突,可能会导致无法正常使用ScriptCat'
191-
);
192-
}
193-
});

src/pkg/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Storage } from '@App/pkg/storage/storage'
44
import { ChromeStorage } from './storage/chrome';
55

66
export const SYSTEM_CONFIG_CHANGE = 'system_config_change';
7+
78
//NOTE: 可以抽象set接口
89
export class SystemConfig {
910

src/types/scriptcat.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ declare function GM_cookie(action: GM_Types.CookieAction, details: GM_Types.Cook
108108
// 通过tabid(前后端通信可能用到,ValueChangeListener会返回tabid),获取storeid,后台脚本用.
109109
declare function GM_getCookieStore(tabid: number, ondone: (storeId: number, error: any | undefined) => void): void;
110110

111+
// 正式版中以废弃
111112
declare function CAT_setProxy(rule: CAT_Types.ProxyRule[] | string): void;
113+
// 正式版中以废弃
112114
declare function CAT_clearProxy(): void;
115+
// 正式版中以废弃
113116
declare function CAT_click(x: number, y: number): void;
114-
declare function CAT_createFile(file: string | Blob, name: string, ondone?: (download: boolean, error?: any | undefined) => void): void;
115117

116118
declare namespace CAT_Types {
117119
interface ProxyRule {

0 commit comments

Comments
 (0)