tianyun há 3 anos atrás
pai
commit
97aabc7bd8
2 ficheiros alterados com 42 adições e 4 exclusões
  1. 27 0
      tmp/monkey/tmp.js
  2. 15 4
      tmp/monkey/web-history.js

+ 27 - 0
tmp/monkey/tmp.js

@@ -0,0 +1,27 @@
+// ==UserScript==
+// @name              T-美妆-爬虫
+// @author            tianyunperfect
+// @description       简介
+// @version           1.0.0
+// @update            2021-07-08 16:16:14
+// @grant             GM_registerMenuCommand
+// @include           https://bebd.bevol.com/ranking?type=category
+// @require           https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/tmp/monkey/util.js?a=1
+// @require     https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
+
+// ==/UserScript==
+(async () => {
+    GM_registerMenuCommand("!!!复制并加到memory", do1);
+    async function do1 () {
+        let res =[]
+        let rows = (await getDomAll(".ant-table-tbody [data-row-key]"))
+        for (let x in rows) {
+            if (x < 50) {
+                res.push(rows[x].getAttribute("data-row-key"));
+            }
+        }
+        console.log(res)
+    };
+
+
+})();

+ 15 - 4
tmp/monkey/web-history.js

@@ -22,13 +22,24 @@
         }
     }
 
+    function getKey() {
+        return "t_href" + location.href;
+    }
+
+    function setTitle() {
+        localStorage.setItem(getKey(), document.title);
+    }
+
+    function checkTitle() {
+        return localStorage.getItem(getKey()) !== document.title
+    }
+
     setTimeout(() => {
-        let t_href = "t_href"
-        localStorage.setItem(t_href, document.title);
+        setTitle();
         save();
         setInterval(() => {
-            if (localStorage.getItem(t_href) !== document.title) {
-                localStorage.setItem(t_href, document.title);
+            if (checkTitle()) {
+                setTitle();
                 save();
             }
         }, 5000)