|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name Greasy Fork++
|
3 | 3 | // @namespace https://github.com/iFelix18
|
4 |
| -// @version 3.3.0 |
| 4 | +// @version 3.3.1 |
5 | 5 | // @author CY Fung <https://greasyfork.org/users/371179> & Davide <[email protected]>
|
6 | 6 | // @icon https://www.google.com/s2/favicons?domain=https://greasyfork.org
|
7 | 7 | // @description Adds various features and improves the Greasy Fork experience
|
@@ -1046,6 +1046,60 @@ inIframeFn() || (async () => {
|
1046 | 1046 | return null;
|
1047 | 1047 | }
|
1048 | 1048 |
|
| 1049 | + const ruleFn = function (text) { |
| 1050 | + /** @type {String[]} */ |
| 1051 | + const { rules, regExpArr } = this; |
| 1052 | + let text0 = text.replace(/\uE084/g, '\uE084x'); |
| 1053 | + let j = 0; |
| 1054 | + for (const rule of rules) { |
| 1055 | + let r = false; |
| 1056 | + if (!rule.includes('\uE084')) { |
| 1057 | + r = (text.toLocaleLowerCase("en-US").includes(rule.toLocaleLowerCase("en-US"))); |
| 1058 | + } else { |
| 1059 | + const s = rule.split(/\uE084(\d+)r/); |
| 1060 | + r = s.every((t, i) => { |
| 1061 | + if (t === undefined || t.length === 0) return true; |
| 1062 | + if (i % 2) { |
| 1063 | + return regExpArr[+t].test(text0); |
| 1064 | + } else { |
| 1065 | + return text0.includes(t.trim()); |
| 1066 | + } |
| 1067 | + }); |
| 1068 | + } |
| 1069 | + if (r) return j; |
| 1070 | + j++; |
| 1071 | + } |
| 1072 | + } |
| 1073 | + |
| 1074 | + /** @param {String} txtRule */ |
| 1075 | + const preprocessRule = (txtRule) => { |
| 1076 | + const regExpArr = []; |
| 1077 | + txtRule = txtRule.replace(/\uE084/g, '\uE084x'); |
| 1078 | + let maxCount = 800; // avoid deadloop |
| 1079 | + while (maxCount--) { |
| 1080 | + const idx1 = txtRule.search(/\bre\//); |
| 1081 | + if (idx1 < 0) break; |
| 1082 | + const str = txtRule.substring(idx1 + 3); |
| 1083 | + let idx2 = -1; |
| 1084 | + const searcher = /(.?)\//g; |
| 1085 | + let m; |
| 1086 | + while (m = searcher.exec(str)) { |
| 1087 | + if (m[1] === '\\') continue; |
| 1088 | + idx2 = searcher.lastIndex + idx1 + 3; |
| 1089 | + break; |
| 1090 | + } |
| 1091 | + if (idx2 < 0) break; |
| 1092 | + const optionStr = txtRule.substring(idx2); |
| 1093 | + const optionM = /^[a-z]+/.exec(optionStr); |
| 1094 | + const option = optionM ? optionM[0] : ''; |
| 1095 | + const regexContent = txtRule.substring(idx1 + 2 + 1, idx2 - 1); |
| 1096 | + txtRule = `${txtRule.substring(0, idx1)}${('\uE084' + regExpArr.length + 'r')}${txtRule.substring(idx2 + option.length)}`; |
| 1097 | + regExpArr.push(new RegExp(regexContent, option)); |
| 1098 | + } |
| 1099 | + const rules = txtRule.split(',').map(e => e.trim()); |
| 1100 | + return ruleFn.bind({ rules, regExpArr }); |
| 1101 | + } |
| 1102 | + |
1049 | 1103 | const useHashedScriptName = true;
|
1050 | 1104 | const fixLibraryScriptCodeLink = true;
|
1051 | 1105 | const addAdditionInfoLengthHint = true;
|
@@ -1143,7 +1197,7 @@ inIframeFn() || (async () => {
|
1143 | 1197 | });
|
1144 | 1198 | gmc.initialized = new Promise(r => (gmc.initializedResolve = r));
|
1145 | 1199 | await gmc.initialized.then();
|
1146 |
| - const customBlacklistRE = createRE((gmc.get('customBlacklist') || '').replace(/\s/g, '').split(',').join('|'), 'giu'); |
| 1200 | + const customBlacklistRF = preprocessRule(gmc.get('customBlacklist') || ''); |
1147 | 1201 |
|
1148 | 1202 | const valHideRecentUsersWithin_ = Math.floor(+gmc.get('hideRecentUsersWithin'));
|
1149 | 1203 | const valHideRecentUsersWithin = valHideRecentUsersWithin_ > 168 ? 168 : valHideRecentUsersWithin_ > 0 ? valHideRecentUsersWithin_ : 0;
|
@@ -2099,8 +2153,8 @@ inIframeFn() || (async () => {
|
2099 | 2153 | }
|
2100 | 2154 | break;
|
2101 | 2155 | case 'customBlacklist': {
|
2102 |
| - const customBlacklist = customBlacklistRE; |
2103 |
| - if (customBlacklist && (customBlacklist.test(name) || customBlacklist.test(description)) && !element.classList.contains('blacklisted')) { |
| 2156 | + const customBlacklist = customBlacklistRF; |
| 2157 | + if (customBlacklist && (customBlacklist(name) >= 0 || customBlacklist(description) >= 0) && !element.classList.contains('blacklisted')) { |
2104 | 2158 | element.classList.add('blacklisted', 'custom-blacklist');
|
2105 | 2159 | if (gmc.get('hideBlacklistedScripts') && gmc.get('debugging')) {
|
2106 | 2160 | let scriptLink = element.querySelector('.script-link');
|
|
0 commit comments