cleanup: remove old Muse-named scriptlet fallback file
Browse files
src-tauri/resources/scriptlets/muse_ubo_compatible_scriptlets.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
| 1 |
-
/// json-prune.js
|
| 2 |
-
(function() {
|
| 3 |
-
'use strict';
|
| 4 |
-
const args = Array.from(arguments);
|
| 5 |
-
const prunePaths = (args[0] || '').split(/\s+/).filter(Boolean);
|
| 6 |
-
if (prunePaths.length === 0) return;
|
| 7 |
-
function prune(obj, path) {
|
| 8 |
-
if (!obj || typeof obj !== 'object') return;
|
| 9 |
-
const parts = path.split('.');
|
| 10 |
-
let target = obj;
|
| 11 |
-
for (let i = 0; i < parts.length - 1; i++) {
|
| 12 |
-
const part = parts[i];
|
| 13 |
-
if (part.endsWith('[]')) {
|
| 14 |
-
const key = part.slice(0, -2);
|
| 15 |
-
if (Array.isArray(target[key])) {
|
| 16 |
-
target[key].forEach(item => prune(item, parts.slice(i + 1).join('.')));
|
| 17 |
-
}
|
| 18 |
-
return;
|
| 19 |
-
}
|
| 20 |
-
if (!target[part]) return;
|
| 21 |
-
target = target[part];
|
| 22 |
-
}
|
| 23 |
-
delete target[parts[parts.length - 1]];
|
| 24 |
-
}
|
| 25 |
-
function pruneAll(obj) { for (const p of prunePaths) prune(obj, p); return obj; }
|
| 26 |
-
const jp = JSON.parse;
|
| 27 |
-
JSON.parse = function() { return pruneAll(jp.apply(this, arguments)); };
|
| 28 |
-
const rj = Response.prototype.json;
|
| 29 |
-
Response.prototype.json = function() { return rj.apply(this, arguments).then(pruneAll); };
|
| 30 |
-
})();
|
| 31 |
-
|
| 32 |
-
/// set-constant.js
|
| 33 |
-
(function() {
|
| 34 |
-
'use strict';
|
| 35 |
-
const prop = arguments[0];
|
| 36 |
-
const raw = arguments[1];
|
| 37 |
-
if (!prop) return;
|
| 38 |
-
let value;
|
| 39 |
-
if (raw === 'undefined') value = undefined;
|
| 40 |
-
else if (raw === 'false') value = false;
|
| 41 |
-
else if (raw === 'true') value = true;
|
| 42 |
-
else if (raw === 'null') value = null;
|
| 43 |
-
else value = raw;
|
| 44 |
-
const parts = prop.split('.');
|
| 45 |
-
let obj = window;
|
| 46 |
-
for (let i = 0; i < parts.length - 1; i++) {
|
| 47 |
-
obj = obj[parts[i]] = obj[parts[i]] || {};
|
| 48 |
-
}
|
| 49 |
-
try {
|
| 50 |
-
Object.defineProperty(obj, parts[parts.length - 1], { get: () => value, set: () => {}, configurable: true });
|
| 51 |
-
} catch {}
|
| 52 |
-
})();
|
| 53 |
-
|
| 54 |
-
/// abort-current-script.js
|
| 55 |
-
(function() {
|
| 56 |
-
'use strict';
|
| 57 |
-
const needle = arguments[0] || '';
|
| 58 |
-
const prop = arguments[1] || '';
|
| 59 |
-
if (!needle && !prop) return;
|
| 60 |
-
const re = new RegExp(needle);
|
| 61 |
-
const oe = document.createElement.bind(document);
|
| 62 |
-
document.createElement = function(tag) {
|
| 63 |
-
const el = oe(tag);
|
| 64 |
-
if (String(tag).toLowerCase() === 'script') {
|
| 65 |
-
const set = el.setAttribute.bind(el);
|
| 66 |
-
el.setAttribute = function(name, value) {
|
| 67 |
-
if (name === 'src' && re.test(String(value))) return;
|
| 68 |
-
return set(name, value);
|
| 69 |
-
};
|
| 70 |
-
}
|
| 71 |
-
return el;
|
| 72 |
-
};
|
| 73 |
-
})();
|
| 74 |
-
|
| 75 |
-
/// prevent-fetch.js
|
| 76 |
-
(function() {
|
| 77 |
-
'use strict';
|
| 78 |
-
const needle = arguments[0] || '';
|
| 79 |
-
if (!needle) return;
|
| 80 |
-
const re = new RegExp(needle);
|
| 81 |
-
const of = window.fetch;
|
| 82 |
-
window.fetch = function(input, init) {
|
| 83 |
-
const url = typeof input === 'string' ? input : input && input.url || '';
|
| 84 |
-
if (re.test(url)) return Promise.resolve(new Response('', { status: 204 }));
|
| 85 |
-
return of.apply(this, arguments);
|
| 86 |
-
};
|
| 87 |
-
})();
|
| 88 |
-
|
| 89 |
-
/// m3u8-prune.js
|
| 90 |
-
(function() {
|
| 91 |
-
'use strict';
|
| 92 |
-
const needle = arguments[0] || 'stitched-ad|advertisement|DATERANGE';
|
| 93 |
-
const re = new RegExp(needle);
|
| 94 |
-
const of = window.fetch;
|
| 95 |
-
window.fetch = function(input, init) {
|
| 96 |
-
const url = typeof input === 'string' ? input : input && input.url || '';
|
| 97 |
-
return of.apply(this, arguments).then(resp => {
|
| 98 |
-
if (!String(url).includes('.m3u8')) return resp;
|
| 99 |
-
return resp.clone().text().then(text => {
|
| 100 |
-
const out = text.split('\n').filter(line => !re.test(line)).join('\n');
|
| 101 |
-
return new Response(out, { status: resp.status, headers: resp.headers });
|
| 102 |
-
}).catch(() => resp);
|
| 103 |
-
});
|
| 104 |
-
};
|
| 105 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|