微信公众号文章菜单选项

微信公众号文章菜单选项,展示一些有用的选项。

目前为 2023-03-09 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Wechat Article Menu
  3. // @name:zh-CN 微信公众号文章菜单选项
  4. // @description Wechat Article Menu, Show Some Useful Options.
  5. // @description:zh-CN 微信公众号文章菜单选项,展示一些有用的选项。
  6. // @namespace https://www.runningcheese.com
  7. // @version 0.2
  8. // @author RunningCheese
  9. // @match https://mp.weixin.qq.com/s/*
  10. // @match https://mp.weixin.qq.com/s?__biz=*
  11. // @run-at document-start
  12. // @icon https://t1.gstatic.cn/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://mp.weixin.qq.com
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. javascript: (function(n, g, q, c, f) {
  17. var s = document,
  18. l = s.onclick,
  19. h = "ws_cmbm-" + f,
  20. b = s.getElementById(h),
  21. d = "ws_cmbms-" + f,
  22. p = s.getElementById(d),
  23. e = null,
  24. o, a = {
  25. tl: {
  26. left: "10px",
  27. top: "10px"
  28. },
  29. tr: {
  30. right: "10px",
  31. top: "10px"
  32. },
  33. bl: {
  34. left: "10px",
  35. bottom: "10px"
  36. },
  37. br: {
  38. right: "10px",
  39. bottom: "10px"
  40. }
  41. },
  42. k, m = ".ws_cmbmc{position:fixed;z-index:10123456;width:200px;display:block;visibility:hidden;border:1px solid #b0b0b0;background:#fff;padding:3px 0 3px 3px;text-align:left;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;box-shadow:2px 2px 3px #777;-moz-box-shadow:2px 2px 3px #777;-webkit-box-shadow:2px 2px 3px #777;}.ws_cmbmc a{display:block;float:left;margin:0;width:191px;border:none;padding:8px 0 8px 6px;background:#fff;color:black;text-decoration:none;font:normal normal normal 12px/100% Verdana,sans-serif;letter-spacing:normal;word-spacing:normal;}.ws_cmbmc a:hover{background:#a0a0a0;color:white;border:none;text-decoration:none;font:normal normal normal 12px/100% Verdana,sans-serif;letter-spacing:normal;word-spacing:normal;}";
  43.  
  44. function r() {
  45. b.style.visibility = "visible"
  46. }
  47.  
  48. function j() {
  49. b.style.visibility = "visible"
  50. }
  51. if (b) {
  52. if (b.style.visibility == "visible") {
  53. r()
  54. } else {
  55. j()
  56. }
  57. return
  58. }
  59. if (!p) {
  60. m = m.replace(/.ws_cmbmc/g, "#" + h);
  61. p = s.createElement("style");
  62. p.type = "text/css";
  63. p.id = d;
  64. p.appendChild(s.createTextNode(m));
  65. s.getElementsByTagName("head")[0].appendChild(p)
  66. }
  67. b = s.createElement("div");
  68. b.setAttribute("id", h);
  69. b.className = "ws_cmbmc";
  70. for (o = 0; o < n.length; o++) {
  71. e = s.createElement("a");
  72. e.appendChild(s.createTextNode(n[o].title));
  73. e.setAttribute("href", n[o].url);
  74. e.onclick = (function(i) {
  75. if (q) {
  76. r()
  77. }
  78. });
  79. b.appendChild(e)
  80. }
  81. s.getElementsByTagName("body")[0].appendChild(b);
  82. if (a.hasOwnProperty(g)) {
  83. for (k in a[g]) {
  84. b.style[k] = a[g][k]
  85. }
  86. } else {
  87. if (g == "c") {
  88. b.style.left = Math.round((window.innerWidth - b.offsetWidth) / 2) + "px";
  89. b.style.top = Math.round((window.innerHeight - b.offsetHeight) / 2) + "px"
  90. }
  91. }
  92. if (c) {
  93. s.onclick = (function() {
  94. r();
  95. if (typeof l == "function") {
  96. l()
  97. }
  98. });
  99. b.onclick = (function(i) {
  100. i.stopPropagation()
  101. })
  102. }
  103. j()
  104. })([{
  105. title: "文章封面",
  106. url: "javascript:(function() { url = document.querySelector(%22meta[property=\x27twitter:image\x27]%22).content; window.open(url,\x27_blank\x27); })();"
  107. }, {
  108. title: "文章摘要",
  109. url: "javascript:(function() { summary = document.querySelector(\x27meta[name=\x22description\x22]\x27).content; prompt(\x27文章摘要:\x27,summary)})();"
  110. }, {
  111. title: "净化链接",
  112. url: "javascript:(function(){const rules={\x27mp.weixin.qq.com\x27:{testReg:/^http(?:s)?:\\/\\/mp\\.weixin\\.qq\\.com\\/s\\?.*$/i,query:[\x27__biz\x27,\x27idx\x27,\x27mid\x27,\x27sn\x27,\x27src\x27,\x27timestamp\x27,\x27ver\x27,\x27signature\x27]},other:{testReg:/^(http(?:s)?:\\/\\/[^?#]*)[?#].*$/i,query:[\x27id\x27,\x27tid\x27,\x27uid\x27,\x27q\x27,\x27wd\x27,\x27query\x27,\x27keyword\x27,\x27keywords\x27]}};const%20pureUrl=function(url=window.location.href){const%20hash=url.replace(/^[^#]*(#.*)?$/,\x27$1\x27),base=url.replace(/(\\?|#).*$/,\x27\x27);let%20pureUrl=url;const%20getQueryString=function(key){let%20ret=url.match(new%20RegExp(\x27(?:\\\\?|&)(\x27+key+\x27=[^?#&]*)\x27,\x27i\x27));return%20null===ret?\x27\x27:ret[1]},methods={decodeUrl:function(url){return%20decodeURIComponent(url)}};for(let%20i%20in%20rules){let%20rule=rules[i],reg=rule.testReg,replace=rule.replace;if(reg.test(url)){let%20newQuerys=\x27\x27;void%200!==rule.query&&rule.query.length>0&&rule.query.map(query=>{const%20ret=getQueryString(query);\x27\x27!==ret&&(newQuerys+=(newQuerys.length?\x27&\x27:\x27?\x27)+ret)}),newQuerys+=void%200!==rule.hash&&rule.hash?hash:\x27\x27,pureUrl=(void%200===replace?base:url.replace(reg,replace))+newQuerys,void%200!==rule.methods&&rule.methods.length>0&&rule.methods.map(methodName=>{pureUrl=methods[methodName](pureUrl)});break}}return%20pureUrl}();let%20newnode=document.createElement(\x27input\x27);newnode.id=\x27pure-url-for-copy\x27,newnode.value=pureUrl,document.body.appendChild(newnode);let%20copyinput=document.getElementById(\x27pure-url-for-copy\x27);copyinput.select();try{document.execCommand(\x27copy\x27);window.location.href===pureUrl?window.location.reload():window.location.href=pureUrl}catch(err){null!=prompt(\x27%E5%87%80%E5%8C%96%E5%90%8E%E7%9A%84%E7%BD%91%E5%9D%80%E6%98%AF%EF%BC%9A\x27,pureUrl)&&(window.location.href=pureUrl)}document.body.removeChild(copyinput)})();"
  113. }, {
  114. title: "原始链接",
  115. url: "javascript:(function(){prompt( \x27原始链接:\x27, \x27https://mp.weixin.qq.com/s?__biz=\x27+biz+\x27&idx=1&mid=\x27+mid+\x27&sn=\x27+sn)})();"
  116. }, {
  117. title: "历史消息链接",
  118. url: "javascript:(function(){prompt(\x27历史消息链接:\x27,\x27https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=\x27+biz+\x27#wechat_redirect\x27)})()"
  119. }
  120. /* 删除这行
  121. , {
  122. title: "历史消息",
  123. url: "javascript:window.open(\x27https://freewechat.com/a/\x27 + biz);void(0);"
  124. }, {
  125. title: "被删文章查看",
  126. url: "javascript:(function(){ location.href = location.href.replace(\x27mp.weixin.qq.com/s?__biz=\x27, \x27freewechat.com/a/\x27).replace(\x27&idx=2&mid=\x27, \x27/\x27); })();"
  127. }
  128. 删除这行 */
  129. ], "tl", true, true, 1678121690605)
  130.  
  131.  
  132. /*
  133. 注意:
  134. 隐藏的两行注释,而需要魔法才能使用。
  135.  
  136. 缺点:
  137. 历史消息:并不是所有的公众号才能查看历史消息。
  138. 被删文章查看:需要在 https://mp.weixin.qq.com/s?__biz=MzAwMj 这样的被删原始链接上才能使用,如果是 https://mp.weixin.qq.com/s/JRNA5I 这样的简短链接,则无法使用。
  139. */
  140.