-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoss.user.js
98 lines (92 loc) · 3.47 KB
/
oss.user.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
// ==UserScript==
// @name No More ARR Mods
// @version 0.3
// @description you weren't gonna use them anyway
// @author comp500
// @namespace https://infra.link/
// @match https://www.curseforge.com/minecraft/*
// @match https://www.curseforge.com/Minecraft/*
// @match https://legacy.curseforge.com/minecraft/*
// @match https://legacy.curseforge.com/Minecraft/*
// @updateURL https://github.com/comp500/Curseforge-Userscripts/raw/master/oss.user.js
// @downloadURL https://github.com/comp500/Curseforge-Userscripts/raw/master/oss.user.js
// @homepageURL https://github.com/comp500/Curseforge-Userscripts/
// @supportURL https://github.com/comp500/Curseforge-Userscripts/issues/
// @source https://github.com/comp500/Curseforge-Userscripts/
// @run-at document-end
// @grant GM_xmlhttpRequest
// @connect addons-ecs.forgesvc.net
// @connect edge.forgecdn.net
// @connect media.forgecdn.net
// ==/UserScript==
(function() {
"use strict";
let storage = {};
if (localStorage.NoMoreARRMods != null) {
try {
storage = JSON.parse(localStorage.NoMoreARRMods);
} catch (e) {
console.error(e);
storage = {};
}
}
let modRegex = /\/minecraft\/mc-mods\/([a-z][\da-z\-_]{0,127})$/;
let mCreatorDescRegex = /<div class="box p-4 pb-2 project-detail__content" data-user-content>[\w\W]*MCreator[\w\W]*?<\/div>/i;
let openSourceRegex = /Source<svg class="icon icon-offsite-nav" viewBox="0 0 20 20" width="20" height="20"><use xlink:href="[^"]+"\/><\/svg>/;
// haha nice try
let hahaSourceRegex = /<a href="https?:\/\/(www.)?mcreator.(net|com)\/?[^"\n]*" ?class="text-gray-500 hover:no-underline" ?>\s*<span class="b-list-label">\s*Source/i;
let greaseMonkeyXHR = details => {
details.method = details.method ? details.method : "GET";
details.anonymous = true;
details.responseType = details.responseType ? details.responseType : "arraybuffer";
return new Promise((resolve, reject) => {
details.onload = resolve;
details.onerror = reject;
GM_xmlhttpRequest(details);
});
};
Promise.all(
Array.from(document.querySelectorAll(".project-listing-row")).map(async row => {
let link = Array.from(row.getElementsByTagName("a")).find(a => modRegex.test(a.href));
if (link != undefined) {
let stored = (link.href
.replace("https://legacy.curseforge.com/minecraft/mc-mods/", "")
.replace("https://legacy.curseforge.com/Minecraft/mc-mods/", "")
.replace("https://www.curseforge.com/minecraft/mc-mods/", "")
.replace("https://www.curseforge.com/Minecraft/mc-mods/", ""));
if (storage[stored] == "arr") {
row.parentNode.removeChild(row);
return;
} else if (storage[stored] == "normal" || stored == "thanos-skin") {
return;
}
let res = await fetch(link.href);
if (res.status !== 200) {
console.error("NoMoreARRMods: failed to get mod page " + link.href);
console.log(res);
return;
}
let text = await res.text();
// Exclude mods with MCreator in the description
if (mCreatorDescRegex.test(text)) {
storage[stored] = "arr";
row.parentNode.removeChild(row);
return;
}
// Allow only OSS mods
if (openSourceRegex.test(text) && !hahaSourceRegex.test(text)) {
storage[stored] = "normal";
} else {
storage[stored] = "arr";
row.parentNode.removeChild(row);
}
}
})
)
.then(a => {
localStorage.NoMoreARRMods = JSON.stringify(storage);
})
.catch(e => {
console.error(e);
});
})();