Browse Source

Merge branch 'dev_1.1.1' of https://git.yishihui.com/DeNet/de-net into dev_1.1.1

zhangwei 2 years ago
parent
commit
8083a9ca02
1 changed files with 14 additions and 8 deletions
  1. 14 8
      src/logic/content/nft.js

+ 14 - 8
src/logic/content/nft.js

@@ -36,6 +36,9 @@ export const showNFTGroupIcon = () => {
 export const showNFTGroupList = (e) => {
     let { top, left } = getOffsetRect(e.target);
     let oTop = top + e.target.offsetHeight + 10;
+    // 居底判断
+    let wHeight = document.body.offsetHeight || document.body.clientHeight;
+    if ((top + e.target.offsetHeight + 290) > wHeight) oTop = top - 290;
     let iframe = document.createElement('iframe');
         iframe.src = chrome.runtime.getURL(`/iframe/nft-group.html`)
         iframe.style.cssText = 'border:medium none; width:315px; height:260px;';
@@ -72,8 +75,8 @@ export const checkUserJoinGroup = (fn) => {
                     pageSize: 1
                 }
             }).then(res => {
-                let { data } = res;
-                if (data !== null) {
+                let { data = [] } = res;
+                if (data !== null && data.length > 0) {
                     ifShowNftGroup = true;
                     if (fn) fn()
                 }
@@ -115,12 +118,15 @@ export const setPostContent = (res) => {
 export const setNFTGroupContent = (res) => {
     tempNftGroupPost = res;
 
-    let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
-    if (bigBtn) {
-        bigBtn.click();
-    } else {
-        let smallBtn = document.querySelector('a[href="/compose/tweet"]')
-        smallBtn && smallBtn.click();
+    let dialogDiv = document.querySelectorAll('div[role="dialog"]');
+    if (dialogDiv.length === 0) {
+        let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
+        if (bigBtn) {
+            bigBtn.click();
+        } else {
+            let smallBtn = document.querySelector('a[href="/compose/tweet"]')
+            smallBtn && smallBtn.click();
+        }
     }
 
     let edit = document.querySelector('div[contenteditable="true"]')