Advertisement
video_game

Vattu Page Turner

Nov 4th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         VattuPageturner
  3. // @require      https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  4. // @version      1
  5. // @description  Arrow keys turn pages of Vattu, thanks/apologies to Billy King
  6. // @include      http://*rice-boy.com/vattu/*
  7. // ==/UserScript==
  8. //Returns variable from URL stored with PHP GET format in variable str
  9. function getURLVars(str) {
  10.     var vars = {};
  11.     var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  12.         vars[key] = value;
  13.     });
  14.     return vars[str];
  15. }
  16. function main() {
  17.     $('title').append(' - '+getURLVars('c'));
  18.     (new Image()).src = (parseInt(getURLVars('c'))-1)+'.png';
  19.     (new Image()).src = (parseInt(getURLVars('c'))+1)+'.png';
  20.     $(document).keydown(function(e) {
  21.         switch(e.which) {
  22.             case 37:
  23.                 window.location='index.php?c='+(parseInt(getURLVars('c'))-1);
  24.                 break;
  25.             case 39:
  26.                 window.location='index.php?c='+(parseInt(getURLVars('c'))+1);
  27.                 break;
  28.         }
  29.     });
  30. }
  31. $(document).ready(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement