forked from quoid/userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
233 lines (232 loc) · 10.2 KB
/
Copy pathdev.js
File metadata and controls
233 lines (232 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
const _browser = {
delay: 200,
platform: "ios",
runtime: {
getURL() {
return "https://www.example.com/";
},
sendNativeMessage(message, responseCallback) {
console.log(`Got message: ${message.name}`);
let response = {};
if (message.name === "POPUP_TOGGLE_EXTENSION") {
//response = {error: "Failed toggle extension"};
response = {success: true};
} else if (message.name === "POPUP_UPDATE_ALL" || message.name === "POPUP_UPDATE_SINGLE") {
response = {error: "Failed refresh scripts"};
response = {
items: [
{
name: "Google Images Restored",
filename: "Google Images Restored.js",
disabled: false,
type: "js"
},
{
name: "Wikipedia Mobile Redirect",
filename: "Wikipedia Mobile Redirect.js",
disabled: true,
type: "js"
},
{
name: "A Special Userscript",
filename: "A Special Userscript.js",
disabled: false,
type: "js"
},
{
name: "CSS Adblock",
filename: "CSS Adblock.css",
disabled: false,
type: "css"
},
{
name: "New Userscript With a Really Really Long Name",
filename: "New Userscript With a Really Really Long Name.css",
disabled: true,
type: "css"
},
{
name: "Subframe Script Managerial Staffing Company",
filename: "Subframe Script.js",
disabled: false,
subframe: true,
type: "css"
}
],
updates: []
};
} else if (message.name === "POPUP_CHECK_UPDATES") {
response = {
updates: [
{
filename: "Google Images Restored.js",
name: "Google Images Restored",
url: "https://www.k21p.com"
},
{
filename: "New Userscript With a Really Really Long Name.js",
name: "New Userscript With a Really Really Long Name",
url: "https://www.filmgarb.com"
}
]
};
} else if (message.name === "POPUP_INIT") {
response.initData = {
active: "true",
items: [
{
name: "Google Images Restored",
filename: "Google Images Restored.js",
disabled: false,
type: "js"
},
{
name: "Subframe Script Managerial Staffing Company",
filename: "Subframe Script.js",
disabled: false,
subframe: true,
type: "css"
}
],
updates: [
{
filename: "Google Images Restored.js",
name: "Google Images Restored",
url: "https://www.k21p.com"
},
{
filename: "New Userscript With a Really Really Long Name.js",
name: "New Userscript With a Really Really Long Name",
url: "https://www.filmgarb.com"
}
]
};
} else if (message.name === "POPUP_MATCHES") {
response = {
matches: [
{
name: "Google Images Restored",
filename: "Google Images Restored.js",
disabled: false,
type: "js"
},
{
name: "Subframe Script Managerial Staffing Company",
filename: "Subframe Script.js",
disabled: false,
subframe: true,
type: "css"
}
]
};
} else if (message.name === "POPUP_UPDATES") {
response = {
updates: [
{
filename: "Google Images Restored.js",
name: "Google Images Restored",
url: "https://www.k21p.com"
},
{
filename: "New Userscript With a Really Really Long Name.js",
name: "New Userscript With a Really Really Long Name",
url: "https://www.filmgarb.com"
}
]
};
} else if (message.name === "REQ_PLATFORM") {
response = {platform: _browser.platform};
} else if (message.name === "TOGGLE_ITEM") {
//response = {error: "Failed to toggle item"};
response = {success: true};
} else if (message.name === "POPUP_OPEN_EXTENSION_PAGE") {
response = {error: "Failed to get page url"};
window.open("https://github.com/quoid/userscripts");
} else if (message.name === "OPEN_SAVE_LOCATION") {
if (_browser.platform === "macos") {
response = {success: true};
} else {
response = {
items: [
{
name: "Google Images Restored",
filename: "Google Images Restored.js",
disabled: false,
type: "js",
metadata: []
},
{
name: "Subframe Script Managerial Staffing Company",
filename: "Subframe Script.js",
disabled: false,
type: "css",
metadata: []
},
{
name: "Another Script from Managerial Staffing Company",
filename: "Cool Script.js",
disabled: false,
type: "js",
metadata: []
}
]
};
}
}
if (!responseCallback) {
return new Promise(resolve => setTimeout(() => resolve(response), _browser.delay));
}
setTimeout(() => {
responseCallback(response);
}, _browser.delay);
}
},
tabs: {
query(message, responseCallback) {
const response = [{url: "https://www.filmgarb.com/foo.user.js", id: 101}];
if (!responseCallback) {
return new Promise(resolve => setTimeout(() => resolve(response), _browser.delay));
}
setTimeout(() => {
responseCallback(response);
}, _browser.delay);
},
sendMessage(tabId, message, responseCallback) {
console.log(`Tab ${tabId} got message: ${message.name}`);
let response = {};
if (message.name === "USERSCRIPT_INSTALL_00") {
response = {success: "Click to install"};
//response.error = "something went wrong";
} else if (message.name === "USERSCRIPT_INSTALL_01") {
//response = {error: "a userscript with this @name value already exists, @name needs to be unique"};
response = {
description: "This userscript re-implements the \"View Image\" and \"Search by image\" buttons into google images.",
grant: ["GM.getValue", "GM.setValue", "GM.xmlHttpRequest"],
match: ["https://www.example.com/*", "https://www.example.com/somethingReallylong/goesRightHere"],
name: "Test Install Userscript",
require: ["https://code.jquery.com/jquery-3.5.1.min.js", "https://code.jquery.com/jquery-1.7.1.min.js"],
source: "https://greasyforx.org/scripts/00000-something-something-long-name/code/Something%20something%20long20name.user.js"
};
}
if (!responseCallback) {
return new Promise(resolve => setTimeout(() => resolve(response), _browser.delay));
}
setTimeout(() => {
responseCallback(response);
}, _browser.delay);
}
},
webNavigation: {
getAllFrames(message, responseCallback) {
const response = [];
if (!responseCallback) {
return new Promise(resolve => setTimeout(() => resolve(response), _browser.delay));
}
setTimeout(() => {
responseCallback(response);
}, _browser.delay);
}
}
};
window.browser = _browser;
document.documentElement.style.backgroundColor = "grey";