Better Primewire

adds popup links to AddToWatched, AddToFavorites, and AddToWatched on some pages.

当前为 2018-03-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better Primewire
  3. // @namespace http://mcimino.reaktix.com/
  4. // @version 0.5.4
  5. // @description adds popup links to AddToWatched, AddToFavorites, and AddToWatched on some pages.
  6. // @match https://www.primewire.ag/*
  7. // @match https://www.primewire.org/*
  8. // @match https://www.primewire.is/*
  9. // @copyright 2012+, You
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. //console.log("towatch",(window.location.href.match(/towatch/)===null),"favorites",(window.location.href.match(/favorites/)===null));
  14. //console.log((window.location.href.match(/towatch/)===null)&(window.location.href.match(/favorites/)===null));
  15.  
  16. //popup = function(x){return window.open("https://www.primewire.ag"+x,"myframe","width=400,height=400");};
  17. popup = function(x){return window.open(window.location.origin+x,"myframe","width=400,height=400");};
  18. debug = 0;
  19.  
  20. for(a=0;a<document.links.length;a++){
  21. if(debug){console.log(0,a);}
  22. var b = document.links[a];
  23. if(debug){console.log(1,b);}
  24.  
  25. //prepend AddToFavs to AddToWatched
  26. c = b.href.match(/(https:..www.primewire.{4,5}addtowatched.php.id.)([0-9]*)(.action.watched.whattodo.add)/);
  27. if(debug){console.log(2,c,c!==null);}
  28. if (c!==null){
  29. if (c.length>0){
  30. d = '<a href="/addtofavs.php?id=' + c[2] + '&whattodo=add">Add to Favs</a> | ' + b.outerHTML;
  31. //console.log(a,d);
  32. b.outerHTML = d;
  33. a+=1;
  34. }
  35. }
  36.  
  37. //prepend AddToWatched to DeleteFav
  38. c = b.href.match(/(https:..www.primewire.{4,5}addtofavs.php.id=)([0-9]*)(.whattodo.delete)/);
  39. if(debug){console.log(3,c,c!==null);}
  40. if (c!==null){
  41. if (c.length>0){
  42. d = '<a href="/addtowatched.php?id=' + c[2] + '&action=watched&whattodo=add">Add to Watched</a> | ' + b.outerHTML;
  43. b.outerHTML = d;
  44. a+=1;
  45. }
  46. }
  47.  
  48. //append AddToWatched AddToFavs to titles, but only if not already looking at the towatch
  49. if ((window.location.href.match(/towatch/)===null)&
  50. (window.location.href.match(/favorites/)===null)&
  51. (window.location.href.match(/watched/)===null)){
  52. c = b.href.match(/(https:..www.primewire.{4,5}watch-)([0-9]*)(.*)/);
  53. if(debug){console.log(4,c,c!==null);}
  54. if (c!==null){
  55. //ignore the Featured list
  56. if (b.innerHTML.slice(0,8)!="<strong>"){
  57. /*
  58. d = '<table style="width:inherit;"><tr>'
  59. d += '<td style="text-align:center"><a href="/addtowatched.php?id=' + c[2] + '&action=towatch&whattodo=add"><img width=15 style="border:0px" src="/images/add_icon_towatch.png" /></a></td>'
  60. d += '<td style="text-align:center"><a href="/addtowatched.php?id=' + c[2] + '&action=watched&whattodo=add"><img width=15 style="border:0px" src="/images/add_icon_watched.png" /></a></td>'
  61. d += '<td style="text-align:center"><a href="/addtofavs.php?id=' + c[2] + '&whattodo=add"><img width=15 style="border:0px" src="/images/add_icon_fav.png" /></a></td>'
  62. d += '</tr></table>'
  63. */
  64.  
  65. d = '<table style="width:inherit;"><tr>';
  66. d += '<td style="text-align:center"><img width=15 style="border:0px" src="/images/add_icon_towatch.png" onclick=\'popup("/addtowatched.php?id=' + c[2] + '&action=towatch&whattodo=add");\'/></td>';
  67. d += '<td style="text-align:center"><img width=15 style="border:0px" src="/images/add_icon_watched.png" onclick=\'popup("/addtowatched.php?id=' + c[2] + '&action=watched&whattodo=add")\'/></td>';
  68. d += '<td style="text-align:center"><img width=15 style="border:0px" src="/images/add_icon_fav.png" onclick=\'popup("/addtofavs.php?id=' + c[2] + '&whattodo=add")\'/></td>';
  69. d += '</tr></table>';
  70.  
  71.  
  72. d = b.outerHTML + d;
  73. b.outerHTML = d;
  74. //a+=3;
  75. //console.log(a,d);
  76. }
  77. }
  78. }
  79. }