煎蛋无聊图跳转按钮

为煎蛋jandan.net/pic提供跳转按钮,输入数字跳转到指定页码

  1. // ==UserScript==
  2. // @name 煎蛋无聊图跳转按钮
  3. // @description 为煎蛋jandan.net/pic提供跳转按钮,输入数字跳转到指定页码
  4. // @namespace http://jandan.net/pic
  5. // @version 0.9
  6. // @description try to take over the world!
  7. // @author whr
  8. // @match http://jandan.net/pic*
  9. // @match http://i.jandan.net/pic*
  10. // @icon http://cdn.jandan.net/static/img/favicon.ico
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Your code here...
  18. //debugger
  19. if(!window.btoa){
  20. alert('该浏览器不支持btoa方法,该脚本[煎蛋无聊图跳转按钮]无法使用')
  21. }
  22. var html_input = '<input class="index" maxlength="4" >'
  23. var html_go = '<a class="go_index" href="#">跳转</a>'
  24. var base_url = 'http://jandan.net/pic/'
  25. var css_obj = {}
  26. if ((/i\.jandan\.net/).test(window.location.href)) {
  27. //移动版
  28. $(".wp-pagenavi").append(html_input);
  29. $(".wp-pagenavi").append(html_go);
  30. //输入框和按钮样式
  31. css_obj = {
  32. "width": "56px",
  33. "height": "36px",
  34. "outline": "none",
  35. "color": "#AAA",
  36. "border": "1px solid #e5e5e5",
  37. "text-align": "center"
  38. };
  39. $(".index").css(css_obj);
  40. $(".go_index").css("margin-left","10px")
  41. //设置跳转链接前半部分
  42. base_url = 'http://i.jandan.net/pic/'
  43. } else {
  44. //桌面版
  45.  
  46. //添加输入框和按钮
  47. $(".cp-pagenavi").append(html_input);
  48. $(".cp-pagenavi").append(html_go);
  49. //输入框和按钮样式
  50. css_obj = {
  51. "width": "56px",
  52. "height": "25px",
  53. "outline": "none",
  54. "color": "#AAA",
  55. "border": "1px solid #e5e5e5",
  56. "text-align": "center"
  57. };
  58. $(".index").css(css_obj);
  59. //设置跳转链接前半部分
  60. base_url = 'http://jandan.net/pic/'
  61. }
  62.  
  63. //跳转方法
  64. function goIndex() {
  65. var index_num = $(".index:eq(0)").val()||$(".index:eq(1)").val()
  66. if (isNaN(Number(index_num))) {
  67. alert("isNaN")
  68. return;
  69. }
  70. var date = new Date().toJSON().substring(0, 10).replace(/-/g, '');
  71. var index_str = date + '-' + index_num;
  72. index_str = btoa(index_str);
  73. var index_href = base_url + index_str
  74. location.href = index_href
  75. }
  76.  
  77. //绑定点击时间和回车监听
  78. $(".go_index").click(goIndex);
  79. $(".index").keydown(function (e) {
  80. if (e.key == "Enter") {
  81. goIndex()
  82. }
  83. })
  84. //点击时清空输入框文本,防止有两个页码
  85. $(".index").focus(function () {
  86. $(".index").val('');
  87. });
  88.  
  89.  
  90. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址