Last active
April 5, 2016 04:04
-
-
Save unitycoder/43f305c6ff5ee026dbf5 to your computer and use it in GitHub Desktop.
LudumDare Theme Slaughter with arrowkeys & GreaseMonkey Firefox plugin
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 LudumDareThemeSlaughterKeyboard | |
// @namespace unitycoder.com | |
// @description use arrowkeys to vote | |
// @include http://ludumdare.com/theme/* | |
// @include http://www.ludumdare.com/theme/* | |
// @version 1.3 | |
// @grant none | |
// ==/UserScript== | |
// OPTIONAL(remove comments from next 2 lines) - Reads the theme name : Powered by TTS-API.COM | |
//var theme = document.querySelector("body > center:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > a:nth-child(1)").innerHTML; | |
//document.querySelector("body").innerHTML +=("<audio autoplay><source src=http://tts-api.com/tts.mp3?q=" + escape(theme) + " type=audio/mpeg></audio>"); | |
// select voting elements | |
var good = document.querySelector("body > center:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > a:nth-child(1)"); | |
var bad = document.querySelector("body > center:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > a:nth-child(1)"); | |
var slaughter = document.querySelector("body > center:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > a:nth-child(1)"); | |
// append arrows | |
good.innerHTML = "< "+good.innerHTML; | |
bad.innerHTML += " >"; | |
slaughter.innerHTML = " \\/ "+slaughter.innerHTML+" \\/"; | |
// listen keys | |
document.onkeydown = KeyListener; | |
function KeyListener(e) | |
{ | |
e = e || window.event; | |
if (e.keyCode == '40') Vote(slaughter); // down arrow (slaughter) | |
if (e.keyCode == '37') Vote(good); // left arrow (good) | |
if (e.keyCode == '39') Vote(bad); // right arrow (bad) | |
} | |
function Vote(obj) | |
{ | |
obj.parentElement.style.backgroundColor = "#00FF00"; | |
// window.location = url; // doesnt set header Referer, in case the server checks it | |
obj.click(); // call click() on the link, sets Referer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment