export let Buffer = require("buffer").Buffer; if (!isBackground) { if (execution_mode == "userscript") { const ocreate = unsafeWindow.document.createElement.bind(document); unsafeWindow.document.createElement = (tag) => { if (tag != "meta") return ocreate(tag); unsafeWindow.document.createElement = ocreate; // restore return unsafeWindow.document.createElement('link'); // whatever to not make 4chanX crash }; } if (execution_mode == "ff_api") { if (typeof cloneInto != "undefined") console.log("CLONE INTO DEFINED"); else console.log("CLONE INTO NOT DEFINED"); let a = 1; console.log(a++); const unsafeWindow = window; //const ogdoc = window.wrappedJSObject.document; console.log(a++); const ocreate = unsafeWindow.document.createElement.bind(document); console.log(a++); exportFunction((tag) => { if (tag != "meta") return ocreate(tag); unsafeWindow.document.createElement = ocreate; // restore return unsafeWindow.document.createElement('link'); // whatever to not make 4chanX crash }, window.document, { defineAs: 'createElement' }); console.log(a++); } }