Mobile01 pager icon

Add 'prev page/next page' icon.

  1. // ==UserScript==
  2. // @name Mobile01 pager icon
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Add 'prev page/next page' icon.
  6. // @author You
  7. // @match https://www.mobile01.com/topicdetail.php?*
  8. // @grant GM_addStyle
  9.  
  10. // @require http://code.jquery.com/jquery-3.4.1.min.js
  11.  
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. GM_addStyle('.m01_pager { font-size:5em; width:70pt; text-align:center; border-radius:10%; position:fixed; background:#aaa; opacity:.5; } \
  18. .m01_next {top:40%; right:10%;} \
  19. .m01_prev {top:40%; left:10%;} \
  20. .m01_pager a {color:#fff; display:block; font-family:"Webdings"} \
  21. .hover {opacity:0.9;} \
  22. ');
  23. // .m01_pager a {color:#fff; display:block; font-family:"Wingdings 3"} \
  24.  
  25. // Your code here...
  26. var prev = $("li.l-pagination__page.is-active").prev()[0];
  27. var next = $("li.l-pagination__page.is-active").next()[0];
  28. var prev_url, next_url;
  29. var prev_html = "<div class='m01_pager m01_prev'>" +
  30. "<a href>3</span></div>";
  31. var next_html = "<div class='m01_pager m01_next'>" +
  32. "<a href>4</span></div>";
  33.  
  34. prev_url = prev ? $('a', prev).attr('href') : "";
  35. next_url = next ? $('a', next).attr('href') : "";
  36.  
  37. console.log(prev,next);
  38. console.log('prev_url = ' + prev_url);
  39. console.log('next_url = ' + next_url);
  40.  
  41. if (prev_url != "")
  42. {
  43. var prev_icon = $(prev_html);
  44. $('a', prev_icon).attr("href", prev_url).attr("title", $('a', prev).attr('data-page'));
  45. $(prev_icon).appendTo("body");
  46. }
  47.  
  48. if (next_url != "")
  49. {
  50. var next_icon = $(next_html);
  51. $('a', next_icon).attr("href", next_url).attr("title", $('a', next).attr('data-page'));
  52. $(next_icon).appendTo("body");
  53. }
  54.  
  55. $(".m01_pager").hover(function(){ $(this).toggleClass('hover');}, function(){$(this).toggleClass('hover');});
  56. })();