🏠 Home 

limitedPagesForHostLoc

try to take over the world!


Install this script?
  1. // ==UserScript==
  2. // @name limitedPagesForHostLoc
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match *://www.hostloc.com/forum*
  8. // @grant none
  9. // @require https://code.jquery.com/jquery-3.4.1.min.js
  10. // ==/UserScript==
  11. $(document).ready(function(){
  12. //to set the less comment number checking whether to read the article
  13. var COMMENTLINE = 20;
  14. //to set the max page number you want to visit
  15. var MAXPAGES = "3";
  16. //get all comments of articles
  17. var comments = $("tbody tr td.num a.xi2");
  18. // console.log(comments);
  19. //this function has disabled
  20. //http://api.w3c.biz/hostloc.php?url=
  21. //check whether the comments is larger than COMMENTLINE
  22. for(var i=0; i < comments.length;i++){
  23. //console.log(comments[i].getAttribute("href"));
  24. if(comments[i].innerText > COMMENTLINE){
  25. window.open("https://www.hostloc.com/" + comments[i].getAttribute("href"));
  26. };
  27. };
  28. //click to next page
  29. var nextPageArray = $(".nxt");
  30. var nextHref = nextPageArray[1].getAttribute("href");
  31. //to get the next page's number
  32. var hrefArray = nextHref.split("-");
  33. console.log(hrefArray);
  34. var nextPageNumber = hrefArray[2].split(".");
  35. console.log( nextPageNumber[0]);
  36. console.log( MAXPAGES);
  37. console.log( nextPageNumber[0].localeCompare(MAXPAGES,undefined, {numeric: true}) );
  38. if( nextPageNumber[0].localeCompare(MAXPAGES ,undefined, {numeric: true}) != 1 ){
  39. console.log("go to next page");
  40. window.open("https://www.hostloc.com/" + nextHref);
  41. window.top.close();
  42. // console.log(nextHref);
  43. }else {
  44. console.log("reach the end");
  45. }
  46. });