Przeglądaj źródła

Merge branch 'edit-bug-22.4.14' into test

zhangwei 3 lat temu
rodzic
commit
7aa4d34e2c

+ 20 - 3
src/entry/background.js

@@ -17,9 +17,9 @@ function onInstalledMethod() {
         name: 'pickup_info',
         url: 'https://de-net-test.piaoquantv.com'
     }, (res) => {
-        if(res) {
-            let {postNickName, srcContentId} = res;
-            if(postNickName && srcContentId) {
+        if (res) {
+            let { postNickName, srcContentId } = res;
+            if (postNickName && srcContentId) {
                 let url = `https://twitter.com/${postNickName}/status/${srcContentId}`
                 chrome.tabs.create({
                     url
@@ -41,6 +41,23 @@ function onInstalledMethod() {
             setChromeStorage({ mid: JSON.stringify(_params) })
         }
     })
+
+    // 无刷新插入js
+    chrome.tabs.query({}, (tab) => {
+        for (let i in tab) {
+            if (tab[i].url.indexOf('twitter.com') >= 0) {
+                chrome.scripting.executeScript({
+                    target: { tabId: tab[i].id },
+                    files: ['js/content.js'],
+                }, () => {
+                    setTimeout(() => {
+                        setChromeStorage({ executeScript: JSON.stringify({executeScript:1}) })    
+                    }, 2000);
+                    
+                })
+            }
+        }
+    })
 }
 
 function onMessageMethod(req, sender, sendResponse) {

+ 15 - 1
src/entry/content.js

@@ -22,7 +22,21 @@ port.onMessage.addListener(function (res) {
     }
 });
 
+chrome.storage.onChanged.addListener(changes => {
+    if (changes.executeScript) {
+        let item = JSON.parse(changes.executeScript.newValue)
+        if (item.executeScript) {
+            init()
+            console.log('yeeee')
+        }
+    }
+})
+
 window.onload = () => {
+    init()
+};
+
+function init() {
     contentTwitterPinLogin(port);
     renderDom(port);
     setIframeRedPacket();
@@ -39,7 +53,7 @@ window.onload = () => {
             chrome.storage.local.remove("popupShowPublishDialog");
         }
     });
-};
+}
 
 window.onmessage = (res) => {
     if (res.data && res.data.actionType) {

+ 3 - 0
src/http/configAPI.js

@@ -0,0 +1,3 @@
+export const appVersionCode = 1
+export const baseUrl = 'https://denettestapi.piaoquantv.com/denet'
+

+ 5 - 3
src/http/request.js

@@ -1,7 +1,7 @@
 import axios from 'axios'
 import { getChromeStorage } from '../uilts/chromeExtension.js'
+import { baseUrl, appVersionCode } from '../http/configAPI.js'
 
-let baseUrl = 'https://denettestapi.piaoquantv.com/denet';
 let userInfo = '';
 let storage_mid = ''
 
@@ -24,7 +24,8 @@ function checkParams(config) {
     if (!baseInfo || !baseInfo.token) {
       config['params']['baseInfo'] = {
         token: token,
-        mid
+        mid,
+        appVersionCode
       }
     }
     let params = {
@@ -38,7 +39,8 @@ function checkParams(config) {
     if (!baseInfo || !baseInfo.token) {
       config['data']['baseInfo'] = {
         token: token,
-        mid
+        mid,
+        appVersionCode
       }
     }
     let data = {

+ 1 - 1
src/manifest.development.json

@@ -39,7 +39,7 @@
         "action",
         "cookies",
         "activeTab",
-        // "scripting",
+        "scripting",
         "storage"
     ],
     "options_page": "options.html",

+ 0 - 98
src/server/redPacket.js

@@ -1,98 +0,0 @@
-let base_url = 'https://denettestapi.piaoquantv.com/denet'
-
-// 获取红包任务详情
-export function getPostDetail() {
-    return new Promise(function (resolve, reject) {
-        let _url = `${base_url}/post/getDetail`
-        fetch(_url, {
-            method: 'POST', // or 'PUT'
-            headers: {
-                'Content-Type': 'application/json',
-            },
-            body: JSON.stringify({
-                "baseInfo": {
-                    "appVersionCode": 0,
-                    "clientTimestamp": 0,
-                    "loginUid": 0,
-                    "requestId": "string",
-                    "token": "string"
-                },
-                "params": {
-                    "postId": "05b2f99bbcfa461db3b053df61ca7ae5"
-                }
-            }),
-        })
-            .then(response => response.json())
-            .then(data => {
-                resolve(data);
-            })
-            .catch((error) => {
-                reject(error);
-            });
-
-    })
-}
-
-// 领取红包任务
-export function getRedPacket() {
-    return new Promise(function (resolve, reject) {
-        let _url = `${base_url}/post/luckdrop/receiveLuckdrop`
-        fetch(_url, {
-            method: 'POST', // or 'PUT'
-            headers: {
-                'Content-Type': 'application/json',
-            },
-            body: JSON.stringify({
-                "baseInfo": {
-                    "appVersionCode": 0,
-                    "clientTimestamp": 0,
-                    "loginUid": 0,
-                    "requestId": "string",
-                    "token": "d2ef1b74d4dec5338938a58b7fe783360612b8a5"
-                },
-                "params": {
-                    "postId": "05b2f99bbcfa461db3b053df61ca7ae5"
-                }
-            }),
-        })
-            .then(response => response.json())
-            .then(data => {
-                resolve(data);
-            })
-            .catch((error) => {
-                reject(error);
-            });
-    })
-}
-
-// 完成红包任务
-export function finishRedPacket() {
-    return new Promise(function (resolve, reject) {
-        let _url = `${base_url}/post/luckdrop/finishLuckdrop`
-        fetch(_url, {
-            method: 'POST', // or 'PUT'
-            headers: {
-                'Content-Type': 'application/json',
-            },
-            body: JSON.stringify({
-                "baseInfo": {
-                    "appVersionCode": 0,
-                    "clientTimestamp": 0,
-                    "loginUid": 0,
-                    "requestId": "string",
-                    "token": "string"
-                },
-                "params": {
-                    "postId": "05b2f99bbcfa461db3b053df61ca7ae5"
-                }
-            }),
-        })
-            .then(response => response.json())
-            .then(data => {
-                resolve(data);
-            })
-            .catch((error) => {
-                reject(error);
-            });
-    })
-}

+ 16 - 7
src/server/twitter.js

@@ -1,9 +1,10 @@
-// twitter专用api
-// import axios from 'axios'
-
+import { appVersionCode } from '../http/configAPI.js'
 let base_url = 'http://testapi.denet.me/denet'
+import {getChromeStorage } from '../uilts/chromeExtension.js'
 
-export function getTtwitterRequestToken() {
+export async function getTtwitterRequestToken() {
+    let storage_mid = await getChromeStorage('mid') || ''
+    const { mid } = storage_mid || {}
     return new Promise(function (resolve, reject) {
         let _url = `${base_url}/user/twitterRequestToken`
         fetch(_url, {
@@ -12,7 +13,10 @@ export function getTtwitterRequestToken() {
                 'Content-Type': 'application/json',
             },
             body: JSON.stringify({
-                "baseInfo": {},
+                "baseInfo": {
+                    appVersionCode,
+                    mid
+                },
                 "params": {
                     "oauthCallback": "oob"
                 }
@@ -28,7 +32,9 @@ export function getTtwitterRequestToken() {
     })
 }
 
-export function twitterLogin(oauthToken, oauthVerifier, receivedIds = []) {
+export async function twitterLogin(oauthToken, oauthVerifier, receivedIds = []) {
+    let storage_mid = await getChromeStorage('mid') || ''
+    const { mid } = storage_mid || {}
     return new Promise(function (resolve, reject) {
         let _url = `${base_url}/user/twitterLogin`
         fetch(_url, {
@@ -37,7 +43,10 @@ export function twitterLogin(oauthToken, oauthVerifier, receivedIds = []) {
                 'Content-Type': 'application/json',
             },
             body: JSON.stringify({
-                "baseInfo": {},
+                "baseInfo": {
+                    appVersionCode,
+                    mid
+                },
                 "params": {
                     "oauthToken": oauthToken,
                     "oauthVerifier": oauthVerifier,

+ 1 - 1
src/view/red-packet.vue

@@ -13,7 +13,7 @@
 
       <div class="list">
         <div class="item" v-for="item, i in data.detail.taskCondition" v-bind:key="i">
-          <template v-if="item.type == 1">
+          <template v-if="item.type == 1 && item.relatedUser && item.relatedUsers.length > 0">
             <div class="item-content">
               <div class="item-follow-title">
                 <img :src="require('../assets/svg/icon-follow.svg')" alt />