tianyunperfect 3 years ago
parent
commit
dcf8dd3873
1 changed files with 11 additions and 8 deletions
  1. 11 8
      tmp/monkey/抖音-复制引用.js

+ 11 - 8
tmp/monkey/抖音-复制引用.js

@@ -5,6 +5,7 @@
 // @grant       none
 // @version     1.0
 // @author      tianyunperfect
+// @require     https://cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.min.js
 // @require     https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/tmp/monkey/util.js?a=2
 // @description 2021/1/30 下午7:09:51
 // ==/UserScript==
@@ -13,28 +14,30 @@
 
     let h1_s = '.z8_VexPf';
     await getDom('.xg-video-container video source');
-    console.log("123")
 
     function getTempId() {
         return "myTmp" + Math.floor(Math.random() * 10000);
     }
 
     function get_video_id() {
-        document.querySelector('.xg-video-container video').querySelectorAll('source').forEach(s => {
+        let source_list = document.querySelector('.xg-video-container video').querySelectorAll('source');
+        for (let s of source_list) {
             let src = s.getAttribute("src");
             let video_id = getQueryStringByUrl(src, "video_id");
-            console.log(video_id)
             if (video_id.length > 0) {
                 return video_id;
             }
-        })
+        }
+        console.log("获取 video——id异常")
+        return '';
     }
-    document.querySelector(h1_s).on('dblclick',()=>{
-        console.log(123)
-        let url = `https://aweme.snssdk.com/aweme/v1/playwm/?video_id=${get_video_id()}`;
+
+    $(h1_s).dblclick(function () {
+        let video_id = get_video_id();
+        let url = `https://aweme.snssdk.com/aweme/v1/playwm/?video_id=${video_id}`;
         myCopy(url);
         let tmpId = getTempId();
-        $("h1_s").eq(0).append(jQuery('<span class="tag" id="' + tmpId + '">:已复制</span>'));
+        $(h1_s).eq(0).append(jQuery('<span class="tag" id="' + tmpId + '">:已复制</span>'));
         setTimeout(() => {
             jQuery('#' + tmpId).remove();
         }, 1500)