This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| let isPressed = false; | |
| let pressTimer = false; | |
| const pressedEvent = new CustomEvent("press", { | |
| bubbles: true, | |
| cancelable: true, | |
| composed: true | |
| }); | |
| const releasedEvent = new CustomEvent("release", { | |
| bubbles: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getRandomIdString = (len = 32) => { | |
| let retVal = ""; | |
| for (let i = 0; i < len; i++) { | |
| const randVal = Math.random(); | |
| retVal += String.fromCharCode((randVal < 0.5 ? ((randVal * 26) + 65) : ((randVal * 10) + 48)) >> 0); | |
| } | |
| return retVal; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "txt2img/Prompt/visible": true, | |
| "txt2img/Prompt/value": "", | |
| "txt2img/Negative prompt/visible": true, | |
| "txt2img/Negative prompt/value": "poorly drawn, disfigured, deformed, cross-eyed, bad anatomy, bad proportions, mutated, extra limbs, extra legs, extra arms, missing limb, missing leg, missing arm, malformed limbs, asymmetrical, close-up, blurred, bad art, ugly, jewellery, hands, fingers", | |
| "txt2img/Styles/visible": false, | |
| "txt2img/Styles/value": [], | |
| "txt2img/Sampling method/visible": true, | |
| "txt2img/Sampling method/value": "DPM++ 2M", | |
| "txt2img/Sampling steps/visible": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getMaxZIndex = () => Array.from(document.querySelectorAll("body *")).reduce((max, elem) => Math.max(max, parseInt(getComputedStyle(elem).zIndex) || 0), 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| globalThis.setImmediate = globalThis.setImmediate || function (callback) { | |
| return setTimeout(callback, 0, ...Array.prototype.slice.apply(arguments, [1])); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = express(); | |
| app.use(async (req, res, next) => { | |
| res.setHeader("Access-Control-Allow-Origin", process.env.ALLOW_ORIGIN); | |
| res.setHeader("Access-Control-Allow-Credentials", true); | |
| res.setHeader("Access-Control-Allow-Headers", "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Slug, X-UID"); | |
| res.setHeader("Access-Control-Allow-Methods", "OPTIONS, POST, PUT, PATCH, GET, DELETE"); | |
| next(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const server = fastify(); | |
| server.addHook("onRequest", async (request, reply) => { | |
| reply.header("Access-Control-Allow-Origin", process.env.ALLOW_ORIGIN); | |
| reply.header("Access-Control-Allow-Credentials", true); | |
| reply.header("Access-Control-Allow-Headers", "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Slug, X-UID"); | |
| reply.header("Access-Control-Allow-Methods", "OPTIONS, POST, PUT, PATCH, GET, DELETE"); | |
| if (request.method === "OPTIONS") { | |
| reply.send(); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.defineProperty(String.prototype, "format", { | |
| "value": function(...args) { | |
| const replacer = function(match, index) { | |
| return (args[parseInt(index)] || ""); | |
| }; | |
| return this.replace(/\${(\d*?)\}/g, replacer); | |
| } | |
| }); | |
| /***********************************************************************************************************/ | |
| /********************************************** Usage **********************************************/ |
Let's say you want to add a method to all the elements in your HTML document. Normally, to do this, you will use Element.prototype as below:
Element.prototype.foo = function() {
return "foo";
};
Let's say now you want to include a library called bar.js in your document. But unbeknownst to to you, there is a piece of code in bar.js that overwrites the foo() method of Element.prototype as below: