Ver código fonte

Merge branch 'dev_1.1.0' into bug_fix_220611_popup

wenliming 2 anos atrás
pai
commit
bee9a4af7a
1 arquivos alterados com 29 adições e 20 exclusões
  1. 29 20
      src/logic/content/ParseCard.js

+ 29 - 20
src/logic/content/ParseCard.js

@@ -41,7 +41,7 @@ class ParseCard {
             let item
             for (let i in arr_shadow) {
                 item = arr_shadow[i].childNodes
-                if(has_denet){
+                if (has_denet) {
                     break
                 }
                 if (item) {
@@ -64,7 +64,7 @@ class ParseCard {
             let arr_article = document.querySelectorAll('article') || []
             let _txt
             for (let i in arr_article) {
-                _txt = arr_article[i].innerText || ''                
+                _txt = arr_article[i].innerText || ''
                 if ((_txt.includes('#DeNet') || _txt.includes('#DNFT') || this.compatibleMask(arr_article[i])) && !this.isHasIframeByArticle(arr_article[i])) {
                     de_net_card.push({
                         time: new Date().getTime(),
@@ -230,24 +230,30 @@ class ParseCard {
 
     createIframe({ post_Id = '', tweet_Id = '', tweet_author = '' }, if_center = false) {
         let _iframe = document.createElement('iframe')
-        let tweet_str = '';
+        let _iframe_url = ''
+        let tweet_str = ''
         if (tweet_Id) {
-            tweet_str = `&tweetId=${tweet_Id}`;
+            tweet_str = `&tweetId=${tweet_Id}`
         }
         _iframe.id = post_Id
-        _iframe.src = chrome.runtime.getURL('/iframe/red-packet.html') + `?postId=${post_Id}${tweet_str}&tweet_author=${tweet_author}&window_origin=${window.location.origin}`;
+        _iframe_url =  chrome.runtime.getURL('/iframe/red-packet.html') + `?postId=${post_Id}${tweet_str}&tweet_author=${tweet_author}&window_origin=${window.location.origin}`;
+        // debugger mode
+        if(window.location.href.includes('denet_debugger')){
+            _iframe_url = _iframe_url + '&denet_debugger=1'
+        }
+        _iframe.src = _iframe_url
         _iframe.style.cssText = 'border:medium none; width:375px; min-height:500px;'
         if (if_center) {
             _iframe.style.cssText = 'border:medium none; width:375px; min-height:500px; display:block; margin:auto;'
         }
         return _iframe
     }
-    createNftIframe({project_Id}) {
+    createNftIframe({ project_Id }) {
         project_Id = project_Id.replace('?', '&');
         let _iframe = document.createElement('iframe')
-            _iframe.id = project_Id
-            _iframe.src = chrome.runtime.getURL('/iframe/nft-card.html') + `?projectId=${project_Id}`;
-            _iframe.style.cssText = 'border:medium none; width:375px; min-height:300px;'
+        _iframe.id = project_Id
+        _iframe.src = chrome.runtime.getURL('/iframe/nft-card.html') + `?projectId=${project_Id}`;
+        _iframe.style.cssText = 'border:medium none; width:375px; min-height:300px;'
         return _iframe
     }
     isHasIframeByArticle(dom_card) {
@@ -336,16 +342,19 @@ class ParseCard {
 
         dom.style = 'min-height:500px'
         if (dom) {
-            // let div = document.createElement('div')
-            // div.style.color = 'red'
-            // div.innerText = `
-            // tweet_Id:${tweet_Id} , 
-            // post_Id:${post_Id}
-            // 获取dom时间:${time}
-            // 短链接:${short_url}
-            // 渲染时长:${(new Date().getTime() - time) / 1000}s
-            // `
-            // dom.parentElement.appendChild(div)
+            // debugger mode
+            if (window.location.href.includes('denet_debugger')) {
+                let div = document.createElement('div')
+                div.style.color = 'red'
+                div.innerText = `
+                tweet_Id:${tweet_Id} , 
+                post_Id:${post_Id}
+                获取dom时间:${time}
+                短链接:${short_url}
+                渲染时长:${(new Date().getTime() - time) / 1000}s
+                `
+                dom.parentElement.appendChild(div)
+            }
             dom.appendChild(this.createIframe({ post_Id, tweet_Id }))
         }
     }
@@ -375,7 +384,7 @@ class ParseCard {
             return
         }
         let dom = dom_card.querySelector('div[id^=jsc_c_]').parentElement
-            dom.style = 'min-height:500px'
+        dom.style = 'min-height:500px'
         if (dom) {
             for (let i = 0; i < dom.childNodes.length; i++) {
                 if (dom.children[i].tagName.toLowerCase() != 'iframe' && (i !== 0)) {