-
Notifications
You must be signed in to change notification settings - Fork 0
/
param.js
31 lines (25 loc) · 936 Bytes
/
param.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
window.userscript_util = window.userscript_util || {};
window.userscript_util.param = {};
window.userscript_util.param.removeParam = (URI, REDUNDANT_PARAM_KEY, GM_info) => {
try {
//querystring to object
const uri = new URI(window.location);
const originalQuery = uri.query();
//filter object key
REDUNDANT_PARAM_KEY
.filter(e => uri.hasQuery(e))
.map(e => uri.removeQuery(e));
//objet to querystring
const newQuery = uri.query();
console.log(newQuery);
//relocate if filtered
if (originalQuery !== newQuery) {
console.log(`UserScript : change to filtered location : ${uri.toString()}`);
history.pushState(null, null, uri.toString());
} else {
console.log("UserScript : no changes");
}
} catch (err) {
userscript_util.exec.logGmError(GM_info, err);
}
};