Created
December 2, 2020 20:20
-
-
Save Lokno/938a22f301ac1c72dd8bd387fb424634 to your computer and use it in GitHub Desktop.
user script for https://adventofcode.com/ that automatically downloads the input for the day in the format dayDD_input.txt
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
| Number.prototype.pad = function(size) { | |
| var s = String(this); | |
| while (s.length < (size || 2)) {s = "0" + s;} | |
| return s; | |
| } | |
| if( document.URL.endsWith('/input') ) | |
| { | |
| var url_sans_input = document.URL.slice(0,document.URL.lastIndexOf('/')) | |
| var day_num = parseInt(url_sans_input.slice(url_sans_input.lastIndexOf('/')+1)) | |
| var bb = new Blob([document.body.innerText], { type: 'text/plain' }); | |
| var a = document.createElement('a'); | |
| a.download = 'day' + day_num.pad(2) + '_input.txt'; | |
| a.href = window.URL.createObjectURL(bb); | |
| a.click(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment