Skip to content

Instantly share code, notes, and snippets.

@derjanb
Last active February 15, 2022 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derjanb/1d490a4a0986aa3fd429968c9375899d to your computer and use it in GitHub Desktop.
Save derjanb/1d490a4a0986aa3fd429968c9375899d to your computer and use it in GitHub Desktop.
(() => {
if (typeof GM_info != 'object' || GM_info.scriptHandler != 'Tampermonkey' || GM_info.version != '4.14') return;
const u_getValue = typeof GM_getValue == 'function' ? GM_getValue : undefined;
const d_getValue = typeof GM == 'object' ? GM.getValue : undefined;
if (u_getValue) {
GM_getValue = this.GM_getValue = (...args) => {
const v = u_getValue(...args);
return JSON.parse(JSON.stringify(v));
}
}
if (d_getValue) {
const opd = Object.getOwnPropertyDescriptors(GM);
this.GM = GM = {};
Object.keys(opd).forEach(k => {
if (k == 'getValue') {
GM.getValue = (...args) => {
return d_getValue(...args).then(v => JSON.parse(JSON.stringify(v)));
}
} else {
Object.defineProperty(GM, k, opd[k]);
}
});
}
if (typeof unsafeWindow != 'undefined') {
const o = {};
const d = Object.getOwnPropertyDescriptors(o.__proto__);
Object.keys(d).forEach(k => window[k] = o[k]);
window.Uint8Array = unsafeWindow.Uint8Array;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment