Aug
8
2015
8
2015
Ludum Dare Theme Slaughter with keyboard
An article by mgear
2 Comments
Quick & dirty GreaseMonkey script (for Firefox) to use Ludum Dare voting page with arrow keys (left = good, right = bad, down = slaughter)
Added also TextToSpeech (reads the theme name), commented out by default, see below.
This file contains 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 | |
} |
Related Posts
2 Comments + Add Comment
Leave a comment to mgear
Recent posts
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
- UnityHub: Add support for custom project title (instead of folder name) or use ProductName
- Testing Unity MUSE AI
- QR Code Generator Online
Recent Comments
@unitycoder_com
My TweetsSubscribe to Blog via Email
Tag Cloud
2d
3D
AI
algorithm
android
asset
build
color
custom
demo
editor
effect
error
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tutorial
ui
unity
vertex
visibility
water
waves
webgl
^ did some cleaning up on the code, and now it also sets Headers/Referrer, using .click(), just in case the server checks for it
Theme Slaughter Command Line (shell script)
http://ludumdare.com/compo/2015/04/03/theme-slaughter-command-line/