-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
RS_SimpleGameGuard.js
104 lines (83 loc) 路 3.27 KB
/
RS_SimpleGameGuard.js
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
//================================================================
// RS_SimpleGameGuard.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2020 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @plugindesc This plugin allows you to reject requesting a specific file during the game. <RS_SimpleGameGuard>
* @author biud436
*
* @param Message
* @type string
* @desc Specify the error message
* @default Abnormal behavior (unencrypted) was detected.
*
* @param Test Mode
* @type boolean
* @desc Check that whether the test mode is valid
* @default true
* @on true
* @off false
*
* @param File Rules
* @type string[]
* @desc Specify the File Rules
* @default ["\\/img\\/characters\\/.*\\.png","\\/audio\\/.*\\/.*\\.(?:m4a|ogg|wav)"]
*
* @help
* ================================================================
* Version Log
* ================================================================
* 2020.03.06 (v1.0.0) - First Release.
*/
var Imported = Imported || {};
Imported.RS_SimpleGameGuard = true;
var RS = RS || {};
RS.SimpleGameGuard = RS.SimpleGameGuard || {};
(function($) {
"use strict";
var parameters = $plugins.filter(function (i) {
return i.description.contains('<RS_SimpleGameGuard>');
});
parameters = (parameters.length > 0) && parameters[0].parameters;
RS.SimpleGameGuard.Params = {};
RS.SimpleGameGuard.Params.message = parameters["Message"];
RS.SimpleGameGuard.Params.isValidTestMode = Boolean(parameters["Test Mode"] === "true");
RS.SimpleGameGuard.Params.fileNotes = JSON.parse(parameters["File Rules"]);
class Guard extends Scene_Boot {
constructor() {
super();
this.run();
}
run() {
if(!Utils.isNwjs()) return;
if(RS.SimpleGameGuard.Params.isValidTestMode) return;
chrome.webRequest.onBeforeRequest.addListener(details => {
if (details.tabId < 0) {
return;
}
chrome.tabs.get(details.tabId, tab => {
if(!tab) {
chrome.tabs.executeScript(details.tabId, {
code: `throw new Error("Cannot find the tab ${tab.id}");`
}, () => { console.log("Injected"); });
}
const method = details.method; // GET, POST
const resUrl = details.url;
RS.SimpleGameGuard.Params.fileNotes.forEach(rules => {
const re = new RegExp(rules, 'gi');
if(re.exec(resUrl)) {
chrome.tabs.executeScript(details.tabId, {
code: `throw new Error("${RS.SimpleGameGuard.Params.message}");`
}, () => { console.log("Injected"); });
}
});
});
}, {urls: ["<all_urls>"]});
}
}
window.Scene_Boot = Guard;
})(RS.SimpleGameGuard);