Created
January 26, 2019 20:25
-
-
Save chuckha/c4b959c9cc87bf75dc874999498627ab to your computer and use it in GitHub Desktop.
auto advance instagram on a timer
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 InstaAutoAdvance | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Automatically advance instagram photos on a timer | |
// @author You | |
// @match https://www.instagram.com/* | |
// @grant none | |
// ==/UserScript== | |
// Type 'niko' to start the script and 'okin' to stop it. | |
(function() { | |
"use strict"; | |
var startKeyword = "niko"; | |
var endKeyword = reverse(startKeyword); | |
var codes = {}; | |
for (var i=0; i < 26; i++) { | |
codes[String.fromCharCode(97+i)] = 97+i; | |
} | |
var minutes = 10; | |
var interval = 1000 * 60 * minutes; | |
var matched = 0; | |
var id = 0; | |
document.addEventListener("keypress", function(input) { | |
// If the id of the interval is set then it should probably stop | |
if (id != 0) { | |
if (input.keyCode === codes[endKeyword[matched]]) { | |
matched++; | |
} else { | |
matched = 0; | |
} | |
if (matched == startKeyword.length) { | |
clearInterval(id); | |
id = 0; | |
matched = 0; | |
} | |
} else { | |
if (input.keyCode === codes[startKeyword[matched]]) { | |
matched++; | |
} else { | |
matched = 0; | |
} | |
if (matched == startKeyword.length) { | |
id = setInterval(function(){ | |
document.getElementsByClassName("coreSpriteRightPaginationArrow")[0].click(); | |
}, interval); | |
matched = 0; | |
} | |
} | |
}); | |
})(); | |
function reverse(s){ | |
return s.split("").reverse().join(""); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment