Skip to content

Commit 445dac9

Browse files
authored
Update unlimitedsaves.user.js
1 parent d236558 commit 445dac9

1 file changed

Lines changed: 51 additions & 21 deletions

File tree

Pixlr.com/UnlimitedSaves/unlimitedsaves.user.js

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @namespace HKR
44
// @match https://pixlr.com/*/*
55
// @grant none
6-
// @version 1.0
6+
// @version 1.1
77
// @author HKR
88
// @description Bypasses the daily save limit
99
// @run-at document-start
@@ -13,30 +13,60 @@
1313
const replacementRegex = /\(\)\s*>=\s*3/g;
1414
const bypassStr = `()=='D'`;
1515

16-
function patchNode(node) {
17-
node?.remove();
16+
if (typeof InstallTrigger !== 'undefined') {
17+
// Firefox method
18+
function patchScript(event) {
19+
const script = event.target;
20+
const src = script?.src;
1821

19-
fetch(node.src)
20-
.then(res => res.text())
21-
.then(text => {
22-
text = text.replace(replacementRegex, bypassStr);
22+
if (src && src.includes('/dist/')) {
23+
event.preventDefault();
2324

24-
if(!text.includes(bypassStr)) {
25-
alert(`Daily limit bypass failed, the userscript may be outdated!`);
26-
}
25+
fetch(src)
26+
.then(res => res.text())
27+
.then(text => {
28+
text = text.replace(replacementRegex, bypassStr);
2729

28-
const newNode = document.createElement('script');
29-
newNode.innerHTML = text;
30+
if (!text.includes(bypassStr)) {
31+
alert(`Daily limit bypass failed, the userscript may be outdated!`);
32+
}
3033

31-
document.body.appendChild(newNode);
34+
const modifiedScript = document.createElement('script');
35+
modifiedScript.innerHTML = text;
36+
37+
script.parentNode.replaceChild(modifiedScript, script);
38+
});
39+
}
40+
}
41+
42+
document.addEventListener('beforescriptexecute', patchScript, true);
43+
} else {
44+
// Chrome method
45+
function patchNode(node) {
46+
node?.remove();
47+
48+
fetch(node.src)
49+
.then(res => res.text())
50+
.then(text => {
51+
text = text.replace(replacementRegex, bypassStr);
52+
53+
if (!text.includes(bypassStr)) {
54+
alert(`Daily limit bypass failed, the userscript may be outdated!`);
55+
}
56+
57+
const newNode = document.createElement('script');
58+
newNode.innerHTML = text;
59+
60+
document.body.appendChild(newNode);
61+
});
62+
}
63+
64+
new MutationObserver(mutationsList => {
65+
mutationsList.forEach(mutationRecord => {
66+
[...mutationRecord.addedNodes]
67+
.filter(node => node.tagName === 'SCRIPT' && node.src?.includes('/dist/'))
68+
.forEach(node => patchNode(node));
3269
});
70+
}).observe(document, { childList: true, subtree: true });
3371
}
34-
35-
new MutationObserver(mutationsList => {
36-
mutationsList.forEach(mutationRecord => {
37-
[...mutationRecord.addedNodes]
38-
.filter(node => node.tagName === 'SCRIPT' && node.src?.includes('/dist/'))
39-
.forEach(node => patchNode(node));
40-
});
41-
}).observe(document, { childList: true, subtree: true });
4272
})();

0 commit comments

Comments
 (0)