├── readme.md └── script.js /readme.md: -------------------------------------------------------------------------------- 1 | # Oracle compute instance creation script 2 | 3 | A JS script that continuously attempts to create an Oracle free tier compute instance. 4 | 5 | ## How to use 6 | 7 | 1. Follow the steps at https://blogs.oracle.com/developers/post/how-to-set-up-and-run-a-really-powerful-free-minecraft-server-in-the-cloud 8 | 2. Ensure all fields are entered correctly as per the blog post above at https://cloud.oracle.com/compute/instances/create 9 | 3. Open dev tools (press F12), and select the 'console' tab 10 | 4. Paste in the contents of [script.js](/script.js) into the console and press enter 11 | 5. Close dev tools, make sure your computer doesn't go to sleep, and pray for the next few hours 12 | 13 | ## Notes 14 | **DO NOT CLOSE THE POPUP WINDOW!** 15 | 16 | Filter logs with '***' to only show outputs from this script. 17 | 18 | It's advised to close dev tools while the script is running, as over long periods of time it may crash (Oracle's fault). 19 | 20 | You can change the interval duration between clicks on the fly by changing the value of the variable `INTERVAL_DURATION` - default is 30 (seconds). -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Find the 'compute' iframe window within the document if it isn't 3 | * already the current window in devtools. 4 | */ 5 | const computeWindow = document.querySelector("#compute-wrapper") 6 | ? window 7 | : document.querySelector("#sandbox-compute-container")?.contentWindow; 8 | if (!computeWindow) 9 | throw new Error("Failed to find iframe window"); 10 | 11 | const createBtn = computeWindow.document.querySelector(".oui-savant__Panel--Footer .oui-button.oui-button-primary"); 12 | if (!createBtn || createBtn.textContent !== "Create") 13 | throw new Error("Failed to find 'Create' button"); 14 | 15 | const contentsElmt = computeWindow.document.querySelector(".oui-savant__Panel--Contents"); 16 | if (!contentsElmt) 17 | throw new Error("Failed to find contents element"); 18 | 19 | const headerElmt = computeWindow.document.querySelector(".oui-savant__Panel--Header"); 20 | if (!headerElmt) 21 | throw new Error("Failed to find header element"); 22 | 23 | /** 24 | * Create a new window to cloud.oracle.com, and then periodically 25 | * refresh it. 26 | * 27 | * We need to periodically regenerate your session token as it 28 | * will probably expire too soon - this script might be running 29 | * for a long time! 30 | */ 31 | const sessionWindow = window.open( 32 | "https://cloud.oracle.com", 33 | "_blank", 34 | "height=400,width=400;popup=true" 35 | ); 36 | 37 | //create the status bar 38 | const statusElmt = document.createElement("div"); 39 | statusElmt.setAttribute("style", ` 40 | z-index: 9999999999999; 41 | position: fixed; 42 | top: 0; 43 | left: 0; 44 | width: 100%; 45 | display: flex; 46 | align-items: center; 47 | justify-content: center; 48 | font-size: 2rem; 49 | color: white; 50 | background-color: #00688c; 51 | box-shadow: 0px 0px 10px -4px black; 52 | white-space: break-spaces; 53 | `); 54 | 55 | /** 56 | * Set the status bar to be the same height as the header. 57 | */ 58 | const setStatusHeight = () => { 59 | statusElmt.style.height = `${headerElmt.clientHeight}px`; 60 | }; 61 | 62 | setStatusHeight(); 63 | computeWindow.addEventListener("resize", setStatusHeight); 64 | contentsElmt.prepend(statusElmt); 65 | 66 | const logStyle = color => `background-color: #222; color: ${color}`; 67 | 68 | console.clear(); 69 | 70 | console.info( 71 | "%c *** Started Oracle compute instance creation script *** ", 72 | logStyle("#e0b414") 73 | ); 74 | console.info( 75 | "%c *** DO NOT CLOSE THE POPUP WINDOW! *** ", 76 | logStyle("#ff4d4d") 77 | ); 78 | console.info( 79 | "%c *** Filter logs with '***' to only show outputs from this script. *** ", 80 | logStyle("#f0dd99") 81 | ); 82 | console.info( 83 | "%c *** It's advised to close dev tools while the script is running, as over long periods of time it may crash (Oracle's fault). *** ", 84 | logStyle("#f0dd99") 85 | ); 86 | console.info( 87 | "%c *** You can change the interval duration between clicks on the fly by changing the value of the variable `INTERVAL_DURATION` - default is 30 (seconds). *** ", 88 | logStyle("#f0dd99") 89 | ); 90 | 91 | const currentTime = () => { 92 | const now = new Date(); 93 | const hours = now.getHours().toString().padStart(2, '0'); 94 | const minutes = now.getMinutes().toString().padStart(2, '0'); 95 | const seconds = now.getSeconds().toString().padStart(2, '0'); 96 | return `${hours}:${minutes}:${seconds}`; 97 | }; 98 | 99 | //you can change this on the fly if you want 100 | let INTERVAL_DURATION = 30; 101 | 102 | const countdownDuration = () => Math.round(INTERVAL_DURATION); 103 | 104 | let countdown = countdownDuration(); 105 | 106 | /** 107 | * Interval to click the 'Create' button and reload the new window 108 | * every `INTERVAL_DURATION` milliseconds. 109 | */ 110 | void setInterval(() => { 111 | if (countdown > 0) { 112 | statusElmt.style.backgroundColor = "#00688c"; 113 | statusElmt.innerHTML = `Clicking in ${countdown} seconds`; 114 | countdown--; 115 | return; 116 | } 117 | 118 | sessionWindow.location.reload(); 119 | createBtn.click(); 120 | statusElmt.style.backgroundColor = "#44bd50"; 121 | statusElmt.innerHTML = `Create clicked!`; 122 | console.log( 123 | `%c *** Clicked 'Create' at ${currentTime()} *** `, 124 | logStyle("#7cde6f") 125 | ); 126 | countdown = countdownDuration(); 127 | }, 1000); --------------------------------------------------------------------------------