Navigate streamallthis.is

haha

当前为 2014-10-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Navigate streamallthis.is
  3. // @namespace http://use.i.E.your.homepage/
  4. // @version 0.1
  5. // @description haha
  6. // @match *streamallthis.is/watch/*/s*
  7. // @copyright 2012+, You
  8. // ==/UserScript==
  9.  
  10.  
  11. var url = window.location.pathname;
  12. var filename = url.substring(url.lastIndexOf('/')+1);
  13. filename = filename.replace(".html","");
  14. filename = filename.replace("s","");
  15. var series = filename.substr(0,filename.indexOf('e'));
  16. var episode = filename.substr(filename.indexOf('e') + 1);
  17.  
  18. if(document.title == '404 Not Found'){
  19. changeSerie();
  20. } else {
  21. var p = document.createElement("P");
  22. p.align = "center";
  23. var prev=document.createElement("input");
  24. prev.type="button";
  25. prev.value="<<= PREV";
  26. prev.onclick = function(){changeEpisode(false)};
  27. p.appendChild(prev);
  28. var next=document.createElement("input");
  29. next.type="button";
  30. next.value="NEXT =>>";
  31. next.onclick = function(){changeEpisode(true)};
  32. p.appendChild(next);
  33. //document.body.appendChild(p);
  34. document.getElementsByClassName("fa")[0].appendChild(p);
  35. }
  36.  
  37. function changeSerie(){
  38. var next = episode > 1;
  39. if (next){
  40. series++;
  41. episode = '01';
  42. series = addMissingZero(series);
  43. window.location.assign(url.substring(0,url.lastIndexOf('/') + 1) + 's' + series + 'e' + episode + '.html');
  44. } else {
  45. series --;
  46. //TODO
  47. }
  48. }
  49.  
  50.  
  51. function changeEpisode(next) {
  52. next ? episode++ : episode--;
  53. episode = addMissingZero(episode);
  54. window.location.assign(url.substring(0,url.lastIndexOf('/') + 1) + 's' + series + 'e' + episode + '.html');
  55. }
  56.  
  57. function addMissingZero(number) {
  58. return (number < 10 ? "0" + number : number);
  59. //return number;
  60. }