Last active
September 10, 2023 06:03
-
-
Save bphamict/3bcae947d149e0dca71f5da860080ef6 to your computer and use it in GitHub Desktop.
modify number on random.org with XHR request
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
| // ==UserScript== | |
| // @name random.org | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Modify number on random.org with XHR request | |
| // @author bphamict | |
| // @match https://www.random.org/widgets/integers/iframe* | |
| // @icon https://www.google.com/s2/favicons?domain=random.org | |
| // @grant none | |
| // @homepage https://gist.github.com/bphamict/3bcae947d149e0dca71f5da860080ef6 | |
| // @updateURL https://gist.github.com/bphamict/3bcae947d149e0dca71f5da860080ef6/raw/random.org.user.js | |
| // @downloadURL https://gist.github.com/bphamict/3bcae947d149e0dca71f5da860080ef6/raw/random.org.user.js | |
| // ==/UserScript== | |
| const winNums = [1, 2, 3]; | |
| (function() { | |
| var open = XMLHttpRequest.prototype.open; | |
| XMLHttpRequest.prototype.open = function() { | |
| this.addEventListener('readystatechange', function() { | |
| if (this.readyState === 4) { | |
| var num = winNums.shift(); | |
| if (num) { | |
| var responseText = this.responseText; | |
| var e = document.createElement('div'); | |
| e.innerHTML = responseText; | |
| e.getElementsByTagName('span')[0].innerText = num + '\n'; | |
| Object.defineProperty(this, 'responseText', {writable: true}); | |
| this.responseText = e.innerHTML; | |
| } | |
| } | |
| }); | |
| return open.apply(this, arguments); | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment