Navigate_streamallthis.is

A little script to navigate trough series at the streaming host <a href="http://streamallthis.is">streamallthis.is</a>

当前为 2015-02-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Navigate_streamallthis.is
  3. // @namespace http://use.i.E.your.homepage/
  4. // @version 0.1.3
  5. // @description A little script to navigate trough series at the streaming host <a href="http://streamallthis.is">streamallthis.is</a>
  6. // @match http://streamallthis.is/watch/*/s*
  7. // @require http://code.jquery.com/jquery-1.11.2.min.js
  8. // @copyright 2012+, greenhalos
  9. // ==/UserScript==
  10.  
  11. $(document).ready(function(){
  12. var url = window.location.pathname;
  13. var filename = url.substring(url.lastIndexOf('/')+1);
  14. filename = filename.replace(".html","");
  15. filename = filename.replace("s","");
  16. var series = filename.substr(0,filename.indexOf('e'));
  17. var episode = filename.substr(filename.indexOf('e') + 1);
  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.id = "next";
  32. p.appendChild(next);
  33. $(".fa").append(p);
  34. $('#next').hide();
  35. $.ajax({
  36. url: genLink(series, parseInt(episode)+1)
  37. }).done(function(){
  38. $("#next").show();
  39. $("#next").click(function(){changeEpisode(true)});
  40. }).fail(function(){
  41. console.log('checking next serie?')
  42. $.ajax({
  43. url: genLink(parseInt(series)+1, 1 )
  44. }).done(function() {
  45. $("#next").show();
  46. $("#next").click(function(){changeSerie()});
  47. });
  48. });
  49. }
  50. function changeSerie(){
  51. var next = episode > 1;
  52. if (next){
  53. series++;
  54. episode = 1;
  55. window.location.assign(genLink(addMissingZero(series),episode));
  56. } else {
  57. series --;
  58. //TODO
  59. }
  60. }
  61. function genLink(genSer, genEpi){
  62. genEpi = addMissingZero(genEpi);
  63. return url.substring(0,url.lastIndexOf('/') + 1) + 's' + genSer + 'e' + genEpi + '.html';
  64. }
  65. function changeEpisode(next) {
  66. next ? episode++ : episode--;
  67. window.location.assign(genLink(series,episode));
  68. }
  69. function addMissingZero(number) {
  70. return (parseInt(number) < 10 ? "0" + number : number);
  71. }
  72. });