klb

提升效率

  1. // ==UserScript==
  2. // @name klb
  3. // @namespace klb.web
  4. // @version 1.10
  5. // @description 提升效率
  6. // @author realyuxia
  7. // @license MIT
  8. // @match https://web2.gzlhzc.cn/index.php
  9. // @match https://web3.gzlhzc.cn/index.php
  10. // ==/UserScript==
  11. (function () {
  12. var qrcode ="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/qrcodejs/1.0.0/qrcode.min.js";
  13. var excludeList = ["描述|缺一不可|样图|一律封号|会一一核对头像审核通过|然后根据提示|点击菜单弹出内容|不准取消关注|切记|名称|必须有最新的回复和最新的菜单点击|请至少保留一个月不要取关感谢大家|再点击全部菜单栏一下|三天内不能马上取关|检测马上取关的一律不通过|关注后按照图中要求点击两个菜单并打开网址|看不到的点击中间更多就显示出来了|一定不要点错了|跪求一礼拜不取关|谢谢|并且截图时间与上传时间吻合|否则会被封号|加人加好友任务截图必须带已发送字样|跪求三天不取关|感谢大家|保留一个星期|不要取消关注|否则将不予通过|然后点击|再点击|否则将不予通过|一定要搜一搜直接搜索|跪求保持1礼拜不取关"];
  14. var keywordsList = ["搜|关注|回复|关注过|关键字|公众号|发送"];
  15.  
  16.  
  17. importjs(qrcode)
  18. addfloatbutton()
  19.  
  20.  
  21. /*import*/
  22. function importjs(url) {
  23. var script = document.createElement("script");
  24. script.type = "text\/javascript";
  25. script.src = url;
  26. document.head.appendChild(script);
  27. }
  28.  
  29. /*floaty*/
  30.  
  31. function addfloatbutton() {
  32. var jump = document.createElement("div");
  33. var qr = document.createElement("div");
  34. var tiaozhuan = document.createElement("div");
  35.  
  36. jump.style.cssText = "border:2px solid red;position:fixed;top:60%;left:80%;width:40px;height:40px;background-color:yellow;z-index:999999;text-align:center;line-height:40px;color:red;box-shadow: 3px 3px 5px #888888;";
  37. qr.style.cssText = "border:2px solid red;position:fixed;top:70%;left:80%;width:40px;height:40px;background-color:yellow;z-index:999999;text-align:center;line-height:40px;color:red;box-shadow: 3px 3px 5px #888888;";
  38. tiaozhuan.style.cssText = "border:2px solid red;position:fixed;top:80%;left:80%;width:40px;height:40px;background-color:yellow;z-index:999999;text-align:center;line-height:40px;color:red;box-shadow: 3px 3px 5px #888888;";
  39.  
  40. jump.textContent = "变换";
  41. jump.addEventListener("click", function (e) {
  42. var t = document.querySelector('#target');
  43. var n = document.querySelector('.gmiaoshu');
  44.  
  45. if (t) {
  46. t.parentElement.removeChild(t)
  47. n.style.display = "block";
  48. jump.textContent = '变换';
  49. } else {
  50. var textnodes = getformattednodes(n)
  51. n.style.display="none";
  52. n.parentElement.appendChild(textnodes);
  53. jump.textContent = '还原';
  54. }
  55. e.stopPropagation();
  56. });
  57.  
  58. qr.textContent = "QR";
  59. qr.addEventListener("click", function (e) {
  60. showQrcode();
  61. e.stopPropagation();
  62. });
  63.  
  64. tiaozhuan.textContent = '跳转';
  65. tiaozhuan.addEventListener('click', function(e){
  66. var aaaNode = document.querySelector('#aaa');
  67. if (aaaNode) {
  68. aaaNode.parentElement.removeChild(aaaNode);
  69. }
  70.  
  71. var url_node = document.querySelector('.getright > .gmoney > textarea');
  72.  
  73. var div = document.createElement('div');
  74. var a = document.createElement('a');
  75.  
  76. div.setAttribute("id", "aaa");
  77. a.setAttribute('href', getUrl(url_node.value));
  78.  
  79. div.appendChild(a);
  80. url_node.parentElement.appendChild(div);
  81.  
  82. a.click();
  83. url_node.parentElement.removeChild(div);
  84. e.stopPropagation();
  85. });
  86.  
  87. document.body.appendChild(jump);
  88. document.body.appendChild(qr);
  89. document.body.appendChild(tiaozhuan);
  90. }
  91.  
  92. /**qrcode */
  93. function showQrcode() {
  94. var qrcode = document.querySelector('#qrcode');
  95. if (qrcode) {
  96. qrcode.parentElement.removeChild(qrcode);
  97. }
  98.  
  99. var url_node = document.querySelector('.getright > .gmoney > textarea');
  100.  
  101. if (!url_node) return;
  102.  
  103.  
  104. var parent = url_node.parentElement;
  105.  
  106. var div = document.createElement('div');
  107.  
  108. div.setAttribute("id", "qrcode");
  109. parent.appendChild(div);
  110.  
  111. var qrcode = new QRCode("qrcode", {
  112. text: getUrl(url_node.value),
  113. render: "png",
  114. width: 200,
  115. height: 200,
  116. colorDark: "#000000",
  117. colorLight: "#ffffff",
  118. correctLevel: 3
  119. });
  120. }
  121. /*filers*/
  122. function gettype(w, excludeList, keywordList) {
  123. var type = 0;
  124.  
  125. keywordList.forEach(function (k) {
  126. var r = new RegExp(k);
  127. if (r.test(w)) {
  128. type = 1;
  129. }
  130. });
  131. excludeList.forEach(function (e) {
  132. var r = new RegExp(e);
  133. if (r.test(w)) {
  134. type = 2;
  135. }
  136. });
  137. return type;
  138. }
  139.  
  140.  
  141. /*返回打散节点*/
  142. function getformattednodes(node) {
  143. var colors = ["#122656", "#73500c", "#FF6666", "#FF33CC", "#CCCC99", "#663366", "#CCCCFF", "#FFFFCC", "#CCFFFF", "#99CC33", "#FF9900", "#FFCC00"];
  144. var nodeText = node.textContent;
  145. var parentNode = node.parentNode;
  146. var newSpan_node = document.createElement('span');
  147. var div_node = document.createElement('div');
  148. var ws = [];
  149.  
  150. /*动画*/
  151. var head = document.head;
  152. var style = document.createElement('style');
  153. var shiftA = "@keyframes shiftN{0%{-webkit-transform:scale(0.5);}50%{-webkit-transform:scale(1.2);}100%{-webkit-transform:scale(1.0);}}";
  154.  
  155. style.innerText = shiftA;
  156. style.type = 'text/css';
  157. head.appendChild(style);
  158.  
  159. div_node.setAttribute('id', 'target');
  160. div_node.style.cssText = "display:block;margin:20px";
  161. ws = sentenceSplitToWords(nodeText);
  162.  
  163. ws.forEach((w) => {
  164. var index = Math.floor(Math.random() * 12);
  165. var n = newSpan_node.cloneNode(false);
  166. n.style.cssText = "font-size: large;display:inline-block;border: 2px dotted #F4A460; margin:10px;";
  167. /* type 1 target; type 2 exclude ; type 0 normal*/
  168.  
  169. switch (gettype(w, excludeList, keywordsList)) {
  170. case 0:
  171. n.style.textShadow = "1px 1px 3px" + colors[index];
  172. break;
  173. case 1:
  174. n.style.backgroundColor = 'DeepPink';
  175. break;
  176. case 2:
  177. n.style.display = "none";
  178. n.style.visibility = "hidden";
  179. break;
  180. default:
  181. }
  182.  
  183. n.textContent = w;
  184. n.addEventListener("click", function (e) {
  185. e.target.style.webkitAnimation = "shiftN 800ms ease-in-out ";
  186. e.target.addEventListener("animationend", function (e) {
  187. e.target.style.webkitAnimation = "";
  188. });
  189. copyText(e.target.textContent);
  190. e.stopPropagation();
  191. });
  192. div_node.appendChild(n);
  193. });
  194. return div_node;
  195. }
  196.  
  197. function sentenceSplitToWords(sentence) {
  198. var s = sentence;
  199. var reg = /[a-zA-Z0-9\u4e00-\u9fa5]+/g;
  200. var ws = [];
  201.  
  202. var match = reg.exec(s);
  203. while (match) {
  204. ws.push(match[0]);
  205. match = reg.exec(s);
  206. }
  207. return ws;
  208. }
  209.  
  210.  
  211. /* util */
  212. function getUrl(str){
  213. var trimed = str.trim(str)
  214. var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi
  215. var urls = trimed.match(reg)
  216. var url = ''
  217. urls.forEach(u=>{
  218. if (u.indexOf('@')===-1) url = u
  219. })
  220. if (url.indexOf("http") === -1) {
  221. /*统一添加协议头 http,无协议头生成的二维码无法直接打开*/
  222. url = "http://" + url
  223. }
  224. return url
  225. }
  226.  
  227. function clipText(source) {
  228. var m = document.createElement('input');
  229. var body = document.querySelector('body');
  230.  
  231. body.appendChild(m);
  232. m.value = source;
  233. m.select();
  234. document.execCommand('copy');
  235. body.removeChild(m);
  236.  
  237. showToast('复制成功', 1500);
  238. }
  239.  
  240. function showToast(msg, duration) {
  241. duration = isNaN(duration) ? 3000 : duration;
  242. var m = document.createElement('div');
  243. m.innerHTML = msg.toString();
  244. m.style.cssText = "width:60%; min-width:180px; background:#000;opacity:0.6; height:auto;min-height: 30px;color:#fff; line-height:30px; text-align:center; border-radius:4px; position:fixed; top:5%; left:20%;z-index:999999;";
  245. document.body.appendChild(m);
  246. setTimeout(function () {
  247. var d = 0.5;
  248. m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
  249. m.style.opacity = '0';
  250. setTimeout(function () { document.body.removeChild(m) }, d * 1000);
  251. }, duration);
  252. }
  253.  
  254. })();
  255.