Tetris Friends Tweaks

Some tweaks on Tetris Friends

当前为 2014-05-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tetris Friends Tweaks
  3. // @description Some tweaks on Tetris Friends
  4. // @include http://www.tetrisfriends.com/*
  5. // @version 0.0.1.20140529093128
  6. // @namespace https://greasyfork.org/users/2233
  7. // ==/UserScript==
  8.  
  9. var wnd = window
  10. var doc = wnd.document
  11. var loc = location
  12. var href = loc.href
  13.  
  14. if(/^http:\/\/www\.tetrisfriends\.com\//.test(href))
  15. {
  16. if(/\/leaderboard\/index\.php$/.test(href))
  17. {
  18. addEventListener("load", function(){ loc.href = 'javascript:window.leaderboardChange("3", "84", 2, "0", 0, "Sprint")' }, false)
  19. throw 'exit'
  20. }
  21. if(!/\/game\.php\b/.test(href)) { throw 'exit' }
  22. wnd.stop()
  23. if(/Live\/game\.php$/.test(href)) { wnd.stop(); loc.href = href+'?das=117&ar=17&ihs=true&irs=true'; throw 'exit' }
  24. addEventListener("DOMContentLoaded", function(){
  25. var game_swf = ''
  26. if(/Sprint\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Sprint/OWGameSprint.swf?version=3" }
  27. else if(/Live\b/.test(href)) { game_swf = "http://www.tetrisfriends.com/data/games/Live/OWGameTetrisLive.swf?livebust=0165?version=0" }
  28. else if(/Ultra\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Ultra/OWGameUltra.swf?version=3" }
  29. else if(/Marathon\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Marathon/OWGameMarathon.swf?version=3" }
  30. else if(/Mono\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Mono/OWGameColorBlind.swf?version=3" }
  31. else if(/Survival\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Survival/OWGameSurvival.swf?version=3" }
  32. else if(/NBlox\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/NBlox/nbloxWebsite.swf?version=3" } // doesn't work
  33. else if(/Battle2P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Battle2P/OWGameBattle2pMaps.swf?version=0" }
  34. else if(/Battle6P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Battle6P/OWGameBattle6P.swf?version=0" }
  35. else if(/Rally8P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Rally8P/OWRally8P.swf?version=0" }
  36. else if(/Sprint5P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Sprint5P/OWGameSprint5p.swf?version=0" }
  37. else { game_swf = doc.getElementsByTagName('OBJECT')[0].data }
  38. if(game_swf == '') { return }
  39.  
  40. var w = '643', h = '381' // change the size of swf as you want
  41. var margin_top = (wnd.innerHeight-h)/2 + 'px'
  42. doc.body.innerHTML = '<object type="application/x-shockwave-flash" allowscriptaccess="always" data="' + game_swf + '" width="' + w + '" height="' + h + '" id="myflash" style="visibility: visible; display: block; margin-left: auto; margin-right: auto; margin-top:' + margin_top + '">' + '<param name="wmode" value="window">' + doc.getElementsByName("flashvars")[0].outerHTML + '<param name="quality" value="low">' + '</object>'
  43. for(var i=doc.styleSheets.length-1; i>=0; i--){ doc.styleSheets[i].disabled=true }
  44. ////for(var i=0; i<3; i++) { // only needed when the <OBJECT> id is 'contentFlash'
  45. ////try {
  46. ////setTimeout(function() {
  47. ////doc.getElementsByTagName('OBJECT')[0].style.cssText = 'visibility: visible; margin-top: 140px; margin-left: 280px;'
  48. ////doc.getElementsByTagName('OBJECT')[0].as3_prerollDone()
  49. ////}, 1000)
  50. ////} catch(e) {}
  51. ////}
  52.  
  53. // buggy...
  54. //doc.getElementsByTagName('OBJECT')[0].onkeydown = function(evt){ alert('onkeydown'); if(evt.keyCode==73) { evt.preventDefault(); doc.getElementsByTagName("OBJECT")[0].as3_tetrisGameRestart() } }
  55. //doc.getElementsByTagName('OBJECT')[0].addEventListener('keydown', function(evt){ alert('keydown'); if(evt.keyCode==73) { evt.preventDefault(); doc.getElementsByTagName("OBJECT")[0].as3_tetrisGameRestart() } }, false)
  56.  
  57. // not yet finished...
  58. //if(/Live\b/.test(href)) { // if one can't connect to arena after a predefined time, reload the page.
  59. //}
  60. }, false)
  61. throw 'exit'
  62. }