-
Notifications
You must be signed in to change notification settings - Fork 373
Expand file tree
/
Copy pathunwrap_test.js
More file actions
66 lines (56 loc) · 1.68 KB
/
Copy pathunwrap_test.js
File metadata and controls
66 lines (56 loc) · 1.68 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
// ==UserScript==
// @name A Scriptlet for @unwrap test
// @namespace none
// @version 2026-02-07
// @description try to take over the world!
// @author You
// @match https://*/*?test_unwrap*
// @exclude /test_\w+_excluded/
// @grant GM_setValue
// @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js#sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK
// @unwrap
// ==/UserScript==
// include: https://example.com/?test_unwrap_123
// exclude: https://example.com/?test_unwrap_excluded
var test_global_injection = "success";
// User can access the variable "test_global_injection" directly in DevTools
(function () {
const results = {
GM: {
expected: "undefined",
actual: typeof GM,
},
GM_setValue: {
expected: "undefined",
actual: typeof GM_setValue,
},
jQuery: {
expected: "function",
actual: typeof jQuery,
},
};
console.group(
"%c@unwrap Test",
"color:#0aa;font-weight:bold"
);
const table = {};
let allPass = true;
for (const key in results) {
const { expected, actual } = results[key];
const pass = expected === actual;
allPass &&= pass;
table[key] = {
Expected: expected,
Actual: actual,
Result: pass ? "✅ PASS" : "❌ FAIL",
};
}
console.table(table);
console.log(
allPass
? "%cAll tests passed ✔"
: "%cSome tests failed ✘",
`font-weight:bold;color:${allPass ? "green" : "red"}`
);
console.groupEnd();
})();