mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 17:25:13 +08:00
update 2026-08-09 04:21:56
This commit is contained in:
1 parent
62707c2029
commit
2ead6d3cf2
1994 files changed
+1524120
-950
No files matched your search
@@ -8,6 +8,22 @@ function arraysEqual(a, b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function decodeIfBase64(str) {
|
||||
try {
|
||||
let s = str.replace(/-/g, '+').replace(/_/g, '/');
|
||||
while (s.length % 4) s += '=';
|
||||
const decoded = decodeURIComponent(
|
||||
atob(s).split('').map(c =>
|
||||
'%' + c.charCodeAt(0).toString(16).padStart(2, '0')
|
||||
).join('')
|
||||
);
|
||||
if (btoa(unescape(encodeURIComponent(decoded))).replace(/=+$/, '') === s.replace(/=+$/, '')) {
|
||||
return decoded;
|
||||
}
|
||||
} catch (e) {}
|
||||
return str;
|
||||
}
|
||||
|
||||
function waitForElement(selector, callback) {
|
||||
const el = document.querySelector(selector);
|
||||
if (el) return callback(el);
|
||||
|
||||
Reference in new issue
Block a user