|
@@ -1,7 +1,8 @@
|
|
|
-import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
|
|
|
-import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl } from '@/uilts/help'
|
|
|
+import { getChromeStorage, setChromeStorage, chromeExtensionUrl } from '@/uilts/chromeExtension.js'
|
|
|
+import { throttle, getQueryString, getCookie, nextTick, getQueryStringByUrl, getStorage, setStorage, getInnerIframeURL, isMobileTwitter } from '@/uilts/help'
|
|
|
import { discordAuthRedirectUri, iframeHost } from '@/http/configAPI'
|
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
+
|
|
|
import Report from "@/log-center/log"
|
|
|
import { fetchAddFinishEvent } from '@/logic/background/fetch/facebook';
|
|
|
import { showNFTGroupIcon, hideNFTGroupList, checkUserJoinGroup, elemAddEventListener, addJoinedGroupList } from '@/logic/content/nft';
|
|
@@ -9,7 +10,10 @@ import { jumpTwitterDetailByAlert, showEditTweet } from '@/logic/content/help/tw
|
|
|
import { clearPostContent, setGroupIconStatus } from '@/logic/content/nft.js'
|
|
|
import { toolBox } from '@/logic/content/ToolBox'
|
|
|
import axios from 'axios';
|
|
|
-import messageCenter from '@/uilts/messageCenter';
|
|
|
+import messageCenter from '@/uilts/messageCenter/content';
|
|
|
+import { PlayType } from '@/types';
|
|
|
+import { reSetBindPostContent } from '@/http/help.js';
|
|
|
+import { setDeviceInfo } from '@/logic/content/help/twitter';
|
|
|
|
|
|
let dom = {};
|
|
|
|
|
@@ -23,6 +27,7 @@ let systemInfo = {
|
|
|
theme: 'light'
|
|
|
}
|
|
|
|
|
|
+
|
|
|
let fixProfileTabAutoTimer = null;
|
|
|
|
|
|
|
|
@@ -59,7 +64,7 @@ function getDiscordAuthCode() {
|
|
|
* @param port
|
|
|
*/
|
|
|
function renderDom() {
|
|
|
- if (window.location.href.indexOf('https://twitter.com') > -1) {
|
|
|
+ if (window.location.href.indexOf('https://twitter.com') > -1 || window.location.href.indexOf('https://mobile.twitter.com') > -1 ) {
|
|
|
_createBtnDom();
|
|
|
onWindowResize();
|
|
|
checkHasDeBtn();
|
|
@@ -116,6 +121,13 @@ export function showTwitterPublishDialogHandler(publishRes) {
|
|
|
// _setPublishContent(publishRes.srcContent);
|
|
|
setDialogPublishContent(publishRes.srcContent);
|
|
|
_publishTweetEvent(publishRes, bindTwitterArtMethod);
|
|
|
+
|
|
|
+ Report.reportLog({
|
|
|
+ businessType: Report.businessType.pageView,
|
|
|
+ objectType: Report.objectType.setPublishContent,
|
|
|
+ postId: publishRes.postId
|
|
|
+ }, {
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
export function twitterPublishHandler(res) {
|
|
@@ -225,12 +237,30 @@ function _publishTweetEvent(params, cb) {
|
|
|
bindTwitterArt.needBind = true;
|
|
|
bindTwitterArt.postId = params.postId;
|
|
|
tweetPublishStore.showPublishDialog = false;
|
|
|
+
|
|
|
+ bindContentStr(params);
|
|
|
// checkIsShowReSend(dialog, params);
|
|
|
cb && cb()
|
|
|
});
|
|
|
}, 800)
|
|
|
}
|
|
|
|
|
|
+function bindContentStr(params) {
|
|
|
+ if (params && params.postBizData) {
|
|
|
+ if (typeof params.postBizData == 'string') {
|
|
|
+ let objBizData = JSON.parse(params.postBizData);
|
|
|
+ let inputEle = document.querySelector('div[contenteditable="true"]');
|
|
|
+ if (objBizData.luckdropType == PlayType.treasure && inputEle) {
|
|
|
+ let textContent = inputEle.innerText;
|
|
|
+ reSetBindPostContent({
|
|
|
+ postId: params.postId,
|
|
|
+ postSrcContent: textContent,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function onClosePublishDialogHandle(dom, params) {
|
|
|
// 如果是 Tool box
|
|
|
if (params.postType == 3) {
|
|
@@ -398,7 +428,7 @@ function _addIframe() {
|
|
|
// let span = document.createElement('span');
|
|
|
// const shadowRoot = span.attachShadow({mode: 'closed'})
|
|
|
let iframe = document.createElement('iframe');
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/publish.html')
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/publish.html')
|
|
|
iframe.id = 'iframe-content'
|
|
|
iframe.style.cssText = 'position:fixed;top:0px;right:0;display:block; width:100%;height:100%;z-index:10000; border: medium none;display:none;background: rgba(255,255,255,0);';
|
|
|
// shadowRoot.appendChild(iframe);
|
|
@@ -421,9 +451,9 @@ function addPublishTipsIframe(params = {}) {
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-publish-tips'
|
|
|
if (params.type == 'nft') {
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/publish-tips.html?type="nft"');
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/publish-tips.html?type="nft"');
|
|
|
} else {
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/publish-tips.html');
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/publish-tips.html');
|
|
|
}
|
|
|
|
|
|
iframe.style.cssText = `border: medium none; width:270px;height:500px;position: fixed; right: ${right}px; top: 5%;z-index: -1`
|
|
@@ -440,7 +470,7 @@ export function noticeBindTweet(params) {
|
|
|
hidePopupPage();
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-notice-bind-tweet';
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/bind-tweet.html') + `?params=${JSON.stringify(params)}`;
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/bind-tweet.html') + `?params=${JSON.stringify(params)}`;
|
|
|
iframe.style.cssText = `border: medium none; width:400px;min-height:313px;position: fixed; right: 16px; top: 16px;border-radius: 20px;`
|
|
|
let iframeContent = document.getElementById('de-notice-bind-tweet');
|
|
|
if (!iframeContent) {
|
|
@@ -529,7 +559,7 @@ const setDialogPublishContent = throttle(function (content) {
|
|
|
if (inputEle) {
|
|
|
inputEle.dispatchEvent(event);
|
|
|
}
|
|
|
- }, 300)
|
|
|
+ }, 800)
|
|
|
}, 600);
|
|
|
|
|
|
/**
|
|
@@ -649,11 +679,22 @@ function createTweetToolbarToolBox() {
|
|
|
function addSliderNavDeBtn() {
|
|
|
try {
|
|
|
let isSmall = false;
|
|
|
+ let isFloating = false;
|
|
|
+ let floatingTweetBtn;
|
|
|
let tweetBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
|
- if (tweetBtn && tweetBtn.querySelector('svg')) {
|
|
|
- isSmall = true;
|
|
|
+ if (tweetBtn) {
|
|
|
+ if (tweetBtn.querySelector('svg')) {
|
|
|
+ isSmall = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 手机打开twitter 发推按钮
|
|
|
+ floatingTweetBtn = document.querySelector('div[data-testid="FloatingActionButtonBase"]');
|
|
|
+ if (floatingTweetBtn) {
|
|
|
+ isFloating = true;
|
|
|
+ }
|
|
|
}
|
|
|
- if (!isSmall) {
|
|
|
+
|
|
|
+ if (!isSmall && !isFloating) {
|
|
|
let bigDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
let deBtn = document.getElementById('de-btn');
|
|
|
if (bigDom && !deBtn) {
|
|
@@ -665,15 +706,19 @@ function addSliderNavDeBtn() {
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
- let smallDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
let deBtn3 = document.getElementById('de-btn3');
|
|
|
- if (smallDom && !deBtn3) {
|
|
|
- dom && dom.deBtn3 && smallDom.appendChild(dom.deBtn3);
|
|
|
- Report.reportLog({
|
|
|
- pageSource: Report.pageSource.mainPage,
|
|
|
- businessType: Report.businessType.buttonView,
|
|
|
- objectType: Report.objectType.buttonMain
|
|
|
- });
|
|
|
+ if (isFloating && !deBtn3) {
|
|
|
+ floatingTweetBtn.appendChild(dom.deBtn3);
|
|
|
+ } else {
|
|
|
+ let smallDom = document.querySelector('a[href="/compose/tweet"]').parentNode.parentNode;
|
|
|
+ if (smallDom && !deBtn3) {
|
|
|
+ dom && dom.deBtn3 && smallDom.appendChild(dom.deBtn3);
|
|
|
+ Report.reportLog({
|
|
|
+ pageSource: Report.pageSource.mainPage,
|
|
|
+ businessType: Report.businessType.buttonView,
|
|
|
+ objectType: Report.objectType.buttonMain
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -766,14 +811,14 @@ export function bindTwitterArtMethod() {
|
|
|
|
|
|
import parseCard from './ParseCard'
|
|
|
|
|
|
-// 检测dom改变
|
|
|
-// 获取短链接
|
|
|
-// 查看本地是否有postid
|
|
|
-// 如果有 修改dom 返回
|
|
|
-// 如果没有 网络请求
|
|
|
-// 获取postid
|
|
|
-// 获取twitterid
|
|
|
-// 检测当前所有dom 如果没有
|
|
|
+// 检测dom改变
|
|
|
+// 获取短链接
|
|
|
+// 查看本地是否有postid
|
|
|
+// 如果有 修改dom 返回
|
|
|
+// 如果没有 网络请求
|
|
|
+// 获取postid
|
|
|
+// 获取twitterid
|
|
|
+// 检测当前所有dom 如果没有
|
|
|
|
|
|
|
|
|
|
|
@@ -808,73 +853,80 @@ function onChangePageMain(targetNode) {
|
|
|
// 2.监听卡片是否可见
|
|
|
// 3.如果可见了 去找
|
|
|
|
|
|
-function setIframeRedPacket(type = 'twitter') {
|
|
|
+function setIframeCard(type = 'twitter') {
|
|
|
// 获取所有卡片参数
|
|
|
let card_json_data
|
|
|
- switch (type) {
|
|
|
- case 'facebook':
|
|
|
- card_json_data = parseCard.parseFacebookCardParmas()
|
|
|
- for (let i in card_json_data) {
|
|
|
- parseCard.replaceFacebookPacket(card_json_data[i])
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- card_json_data = parseCard.parseAllDeNetCardParmas()
|
|
|
- // 过滤出可以请求的短链接
|
|
|
- parseCard.getCardParmas(card_json_data).then((res) => {
|
|
|
- for (let i in res.has_post_Id_card_data) {
|
|
|
- let item = res.has_post_Id_card_data[i];
|
|
|
- if (item && item.post_Id && item.post_Id.indexOf('nft/') >= 0) {
|
|
|
- parseCard.replaceNftDomRedPacket(item)
|
|
|
- } else if (item && item.post_Id && item.post_Id.indexOf('nft_group/') >= 0) {
|
|
|
- parseCard.replaceNftGroupDomRedPacket(item)
|
|
|
- } else if (item && item.post_Id && item.post_Id.indexOf('luckdraw/') >= 0) {
|
|
|
- item.post_Id = item.post_Id.split('luckdraw/')[1] || ''
|
|
|
- item.page_type = '抽奖'
|
|
|
- parseCard.replaceDOMRedPacket(item)
|
|
|
- } else if (item && item.post_Id && item.post_Id.indexOf('toolbox/') >= 0) {
|
|
|
- item.page_type = 'toolbox'
|
|
|
- item.post_Id = item.post_Id.split('toolbox/')[1] || ''
|
|
|
- if (item.post_Id) {
|
|
|
- parseCard.replaceIframeToolBox(item)
|
|
|
- }
|
|
|
- } else if (item && item.post_Id && !item.post_Id.includes('/')) {
|
|
|
- item.page_type = '红包'
|
|
|
- parseCard.replaceDOMRedPacket(item)
|
|
|
- // 夺宝链接
|
|
|
- } else if (item && item.post_Id && item.post_Id.includes('treasure/')) {
|
|
|
- // https://testh5.denetme.net/treasure/{postid}
|
|
|
- // https://testh5.denetme.net/treasure/invite/{inviteCode}
|
|
|
- // 邀请链接
|
|
|
- if (item.post_Id.includes('invite/')) {
|
|
|
- item.invite_code = item.post_Id.split('invite/')[1] || ''
|
|
|
- item.page_type = '邀请链接'
|
|
|
- if (item.invite_code) {
|
|
|
- item.post_Id = ''
|
|
|
- parseCard.replaceDOMTreasureCard(item)
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 原始链接
|
|
|
- item.page_type = '原始链接'
|
|
|
- item.post_Id = item.post_Id.split('treasure/')[1] || ''
|
|
|
- if (item.post_Id) {
|
|
|
- parseCard.replaceDOMTreasureCard(item)
|
|
|
+ if (type == 'facebook') {
|
|
|
+ card_json_data = parseCard.parseFacebookCardParmas()
|
|
|
+ for (let i in card_json_data) {
|
|
|
+ parseCard.replaceFacebookPacket(card_json_data[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (type == 'twitter') {
|
|
|
+ card_json_data = parseCard.parseAllDeNetCardParmas()
|
|
|
+ // 过滤出可以请求的短链接
|
|
|
+ parseCard.getCardParmas(card_json_data).then((res) => {
|
|
|
+ for (let i in res.has_post_Id_card_data) {
|
|
|
+ let item = res.has_post_Id_card_data[i];
|
|
|
+ if (item && item.post_Id && item.post_Id.indexOf('nft/') >= 0) {
|
|
|
+ parseCard.replaceNftDomRedPacket(item)
|
|
|
+ } else if (item && item.post_Id && item.post_Id.indexOf('nft_group/') >= 0) {
|
|
|
+ parseCard.replaceNftGroupDomRedPacket(item)
|
|
|
+ } else if (item && item.post_Id && item.post_Id.indexOf('luckdraw/') >= 0) {
|
|
|
+ item.post_Id = item.post_Id.split('luckdraw/')[1] || ''
|
|
|
+ item.page_type = '抽奖'
|
|
|
+ parseCard.replaceDOMRedPacket(item)
|
|
|
+ } else if (item && item.post_Id && item.post_Id.indexOf('toolbox/') >= 0) {
|
|
|
+ item.page_type = 'toolbox'
|
|
|
+ item.post_Id = item.post_Id.split('toolbox/')[1] || ''
|
|
|
+ if (item.post_Id) {
|
|
|
+ parseCard.replaceIframeToolBox(item)
|
|
|
+ }
|
|
|
+ } else if (item && item.post_Id && !item.post_Id.includes('/')) {
|
|
|
+ item.page_type = '红包'
|
|
|
+ parseCard.replaceDOMRedPacket(item)
|
|
|
+ // 夺宝链接
|
|
|
+ } else if (item && item.post_Id && item.post_Id.includes('treasure/')) {
|
|
|
+ // https://testh5.denetme.net/treasure/{postid}
|
|
|
+ // https://testh5.denetme.net/treasure/invite/{inviteCode}
|
|
|
+ // 邀请链接
|
|
|
+ if (item.post_Id.includes('invite/')) {
|
|
|
+ let arr = item.post_Id.split('/')
|
|
|
+ let index
|
|
|
+ for (let i in arr) {
|
|
|
+ index = Number(i) + 1
|
|
|
+ if (arr[i] == 'invite' && arr.length >= index) {
|
|
|
+ item.invite_code = arr[index];
|
|
|
+ if (arr.length > index + 1) {
|
|
|
+ item.invite_channel = arr[index + 1];
|
|
|
+ } else {
|
|
|
+ item.invite_channel = '';
|
|
|
+ }
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- if (res.need_net_short_url.length > 0) {
|
|
|
- // 请求短链接
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_TWITTER_SHORT_LINK", data: "", arr_url: res.need_net_short_url }, (res) => {
|
|
|
- if (!res) {
|
|
|
- Report.reportLog({
|
|
|
- objectType: Report.objectType.parse_card_error
|
|
|
- });
|
|
|
+
|
|
|
+ item.page_type = '邀请链接'
|
|
|
+ if (item.invite_code) {
|
|
|
+ item.post_Id = ''
|
|
|
+ parseCard.replaceDOMTreasureCard(item)
|
|
|
}
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ // 原始链接
|
|
|
+ item.page_type = '原始链接'
|
|
|
+ item.post_Id = item.post_Id.split('treasure/')[1] || ''
|
|
|
+ if (item.post_Id) {
|
|
|
+ parseCard.replaceDOMTreasureCard(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
- break;
|
|
|
+ }
|
|
|
+ if (res.need_net_short_urls.length > 0) {
|
|
|
+ parseCard.netShortUrl(res.need_net_short_urls, () => {
|
|
|
+ changeQueueNum(5)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -901,7 +953,7 @@ export function initExecuteScript(changes) {
|
|
|
init()
|
|
|
}
|
|
|
}
|
|
|
- if (changes.userInfo) {
|
|
|
+ if (changes.userInfo && changes.userInfo.newValue) {
|
|
|
let item = JSON.parse(changes.userInfo.newValue)
|
|
|
if (item) {
|
|
|
checkUserJoinGroup(() => {
|
|
@@ -940,7 +992,7 @@ function initParseCard() {
|
|
|
return
|
|
|
}
|
|
|
initGroupTip()
|
|
|
- setIframeRedPacket()
|
|
|
+ setIframeCard()
|
|
|
checkHasSliderDeBtn();
|
|
|
changeQueueNum(-1)
|
|
|
showNFTCard()
|
|
@@ -954,7 +1006,7 @@ function initParseCard() {
|
|
|
if (queue_num <= 0) {
|
|
|
return
|
|
|
}
|
|
|
- setIframeRedPacket('facebook')
|
|
|
+ setIframeCard('facebook')
|
|
|
changeQueueNum(-1)
|
|
|
}, 1000)
|
|
|
}
|
|
@@ -999,6 +1051,7 @@ export function init() {
|
|
|
addJoinedGroupList();
|
|
|
getSysTheme();
|
|
|
addGroupTab();
|
|
|
+ setDeviceInfo();
|
|
|
// 预加载全屏 toobbox
|
|
|
toolBox.initFull()
|
|
|
}
|
|
@@ -1031,6 +1084,49 @@ export function init() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+export const getTweetUserFollowStatus = (params) => {
|
|
|
+ let { tweetId, userList, iframeGUId, type } = JSON.parse(params.data);
|
|
|
+ let promiseList = [];
|
|
|
+ for (let i = 0; i < userList.length; i++) {
|
|
|
+ promiseList[i] = TwitterApiUserByScreenNameReq({ screen_name: userList[i]['name'] });
|
|
|
+ }
|
|
|
+
|
|
|
+ Promise.allSettled(promiseList).then((res) => {
|
|
|
+ let list = [];
|
|
|
+ if (res && res.length) {
|
|
|
+ let resList = res.filter(item => item.status == 'fulfilled');
|
|
|
+ for (let i = 0; i < resList.length; i++) {
|
|
|
+ let item = resList[i];
|
|
|
+ if (item && item.value && item.value.data && item.value.data.data) {
|
|
|
+ list.push(item.value.data.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ list, tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: list, tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ }).catch(err => {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ list: [], tweetId, type, iframeId: params.iframeId, iframeGUId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // chrome.runtime.sendMessage({ actionType: 'CONTENT_GET_TWEET_USER_FOLLOW_STATUS_RES', data: [], tweetId, type: params.type, iframeId: params.iframeId }, () => { })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
function onPageVisbile() {
|
|
|
document.addEventListener('visibilitychange', function () {
|
|
|
let isHidden = document.hidden;
|
|
@@ -1073,7 +1169,7 @@ export function facebookReplyTweet(params) {
|
|
|
}
|
|
|
|
|
|
export function replyHandle(params) {
|
|
|
- let iframe = window.parent.document.getElementById(params.postId);
|
|
|
+ let iframe = window.parent.document.getElementById(params.iframeId);
|
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
if (replyBtn) {
|
|
@@ -1096,8 +1192,8 @@ export function replyHandle(params) {
|
|
|
|
|
|
let eleList = tweetReply.parentNode.parentNode.parentNode.parentNode.parentNode.querySelectorAll('span[data-text="true"]');
|
|
|
reportReplyResult(eleList, params, () => {
|
|
|
- // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: { postId: params.postId } }, '*');
|
|
|
+ // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
});
|
|
|
})
|
|
|
}
|
|
@@ -1105,7 +1201,7 @@ export function replyHandle(params) {
|
|
|
}
|
|
|
|
|
|
export function onTweetReplyClick(params) {
|
|
|
- let iframe = window.parent.document.getElementById(params.postId);
|
|
|
+ let iframe = window.parent.document.getElementById(params.iframeId);
|
|
|
let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
if (replyBtn) {
|
|
@@ -1149,13 +1245,35 @@ function onReplyDialogOpen(params, iframe) {
|
|
|
businessType: Report.businessType.buttonClick,
|
|
|
objectType: Report.objectType.replyClickByTwitterList
|
|
|
});
|
|
|
+ let editDom = dialog.querySelector('div[contenteditable="true"]');
|
|
|
+ let eleList = []
|
|
|
+ if(editDom) {
|
|
|
+ eleList = editDom.querySelectorAll('span[data-text="true"]');
|
|
|
+ } else {
|
|
|
+ // mobile.twitter.com
|
|
|
+ editDom = dialog.querySelector('textarea');
|
|
|
+ if(editDom) {
|
|
|
+ let value = editDom.value;
|
|
|
+ if(value) {
|
|
|
+ let strArr = value.split(' ');
|
|
|
+ if(strArr && strArr.length) {
|
|
|
+ for(let i = 0; i < strArr.length; i++) {
|
|
|
+ eleList.push({
|
|
|
+ innerText: strArr[i]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
|
- reportReplyResult(eleList, params, () => {
|
|
|
+ if(eleList.length) {
|
|
|
+ reportReplyResult(eleList, params, () => {
|
|
|
// 上報完成
|
|
|
- // iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: {} }, '*');
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
- })
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_REPLY_RASK_FINSH', data: { postId: params.postId } }, '*');
|
|
|
+ // chrome.runtime.sendMessage({ actionType: "CONTENT_RED_PACKET_REPLY_RASK_FINSH", data: { postId: params.postId } }, () => { })
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}, 1000);
|
|
@@ -1288,10 +1406,12 @@ export function checkTwitterTaskState() {
|
|
|
})
|
|
|
// 点击取消
|
|
|
clickByDataTestId(e, 'confirmationSheetCancel', () => {
|
|
|
+ console.log('DO_TASK1')
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: false }, () => { })
|
|
|
})
|
|
|
// 点击 蒙层
|
|
|
if (e.target && e.target.nextSibling && e.target.nextSibling.dataset && e.target.nextSibling.dataset.testid == 'confirmationSheetDialog') {
|
|
|
+ console.log('DO_TASK2')
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: false }, () => { })
|
|
|
}
|
|
|
}, true)
|
|
@@ -1346,7 +1466,7 @@ export function getTweetAuthorByDom(params) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-export function doTaskTwitterAPI({ task_data, task_type, tasks }) {
|
|
|
+export function doTaskTwitterAPI({ task_data, task_type, tasks, iframeId }) {
|
|
|
switch (task_type) {
|
|
|
case 'like':
|
|
|
TwitterLikeAPI(task_data.tweet_Id)
|
|
@@ -1369,7 +1489,7 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks }) {
|
|
|
case '1':
|
|
|
item.relatedUsers.forEach((item) => {
|
|
|
if (item.name && item.twitterUserId) {
|
|
|
- TwitterFollowAPI(item, task_data.tweet_Id)
|
|
|
+ TwitterFollowAPI(item, task_data.tweet_Id);
|
|
|
}
|
|
|
})
|
|
|
break
|
|
@@ -1381,7 +1501,7 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks }) {
|
|
|
// 推文发推
|
|
|
case '10':
|
|
|
// 发推
|
|
|
- TwitterApiCreateTweet({ text: task_data.tweet_text, tweet_Id: task_data.tweet_Id })
|
|
|
+ TwitterApiCreateTweet({ text: task_data.tweet_text, tweet_Id: task_data.tweet_Id, iframeId })
|
|
|
break
|
|
|
}
|
|
|
|
|
@@ -1390,15 +1510,88 @@ export function doTaskTwitterAPI({ task_data, task_type, tasks }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export function doTaskIframeTwitterAPI(params) {
|
|
|
+ let { tweet_Id, tweet_text, task_type, tasks, iframeGUId } = JSON.parse(params.data);
|
|
|
+ if (task_type == 'tasks') {
|
|
|
+ tasks.forEach((item) => {
|
|
|
+ switch (String(item.type)) {
|
|
|
+ // 关注指定用户
|
|
|
+ case '1':
|
|
|
+ item.relatedUsers.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, tweet_Id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ // 点赞
|
|
|
+ case '2':
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ break
|
|
|
+ // 推文发推
|
|
|
+ case '10':
|
|
|
+ // 发推
|
|
|
+ TwitterApiCreateTweet({ text: tweet_text, tweet_Id, iframeId: params.iframeId, iframeGUId, iframeMsg: true })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (task_type == 'like') {
|
|
|
+ TwitterLikeAPI(tweet_Id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function showJoinDialog(data) {
|
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
|
iframe.style.display = 'block'
|
|
|
iframe.contentWindow.postMessage({ actionType: 'SHOW_JOIN_DATA', data }, '*');
|
|
|
- iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html#/group?params=${JSON.stringify(data)}&time=${new Date().getTime()}`)
|
|
|
+ iframe.src = chromeExtensionUrl + (`iframe/buy-nft.html#/group?params=${JSON.stringify(data)}&time=${new Date().getTime()}`)
|
|
|
+}
|
|
|
+
|
|
|
+const TwitterFriendshipsUpdate = (params) => {
|
|
|
+ let { id = '', device = true, name } = params || {};
|
|
|
+ let data = {
|
|
|
+ include_profile_interstitial_type: 1,
|
|
|
+ include_blocking: 1,
|
|
|
+ include_blocked_by: 1,
|
|
|
+ include_followed_by: 1,
|
|
|
+ include_want_retweets: 1,
|
|
|
+ include_mute_edge: 1,
|
|
|
+ include_can_dm: 1,
|
|
|
+ include_can_media_tag: 1,
|
|
|
+ include_ext_has_nft_avatar: 1,
|
|
|
+ skip_status: 1,
|
|
|
+ cursor: -1,
|
|
|
+ id,
|
|
|
+ device
|
|
|
+ }
|
|
|
+ if (!id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let url = isMobileTwitter() ? 'https://mobile.twitter.com/i/api/1.1/friendships/update.json' : "https://twitter.com/i/api/1.1/friendships/update.json";
|
|
|
+ return fetch(url, {
|
|
|
+ "headers": {
|
|
|
+ "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
+ "content-type": "application/x-www-form-urlencoded",
|
|
|
+ "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
|
|
|
+ "sec-ch-ua-mobile": "?0",
|
|
|
+ "sec-ch-ua-platform": "\"macOS\"",
|
|
|
+ "x-csrf-token": getCookie('ct0'),
|
|
|
+ "x-twitter-active-user": "yes",
|
|
|
+ "x-twitter-auth-type": "OAuth2Session",
|
|
|
+ "x-twitter-client-language": "en",
|
|
|
+ "referer": `https://twitter.com/${name}`
|
|
|
+ },
|
|
|
+ "referrer": `https://twitter.com/${name}`,
|
|
|
+ "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
+ "body": `include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&cursor=-1&id=${id}&device=true`,
|
|
|
+ "method": "POST",
|
|
|
+ "mode": "cors",
|
|
|
+ "credentials": "include"
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
- fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/1.1/friendships/create.json" : "https://twitter.com/i/api/1.1/friendships/create.json"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
@@ -1420,15 +1613,19 @@ const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
let task_data = {
|
|
|
follow_name: item.name
|
|
|
}
|
|
|
+ TwitterFriendshipsUpdate({ id: item.twitterUserId, name: item.name })
|
|
|
+
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: true }, () => { })
|
|
|
}).catch(() => {
|
|
|
+ console.log('DO_TASK3')
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: false }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
const TwitterRetweetAPI = (tweet_Id) => {
|
|
|
- fetch("https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet" : "https://twitter.com/i/api/graphql/ojPdsZsimiJrUGLR1sjUtA/CreateRetweet"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
|
|
@@ -1454,12 +1651,14 @@ const TwitterRetweetAPI = (tweet_Id) => {
|
|
|
}).then(() => {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'retweet', task_data: '', task_done: true }, () => { })
|
|
|
}).catch(() => {
|
|
|
+ console.log('DO0_TASK4')
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'retweet', task_data: '', task_done: false }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
const TwitterLikeAPI = (tweet_Id) => {
|
|
|
- fetch("https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet", {
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet" : "https://twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet"
|
|
|
+ fetch(url, {
|
|
|
"headers": {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1485,12 +1684,13 @@ const TwitterLikeAPI = (tweet_Id) => {
|
|
|
}).then(() => {
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: true }, () => { })
|
|
|
}).catch(() => {
|
|
|
+ console.log('DO_TASK5')
|
|
|
chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: false }, () => { })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-const TwitterApiCreateTweet = ({ text, tweet_Id }) => {
|
|
|
+const TwitterApiCreateTweet = ({ text, tweet_Id, iframeId,
|
|
|
+ iframeGUId, iframeMsg }) => {
|
|
|
let data = {
|
|
|
queryId: "hC1nuE-2d1NX5LYBuuAvtQ",
|
|
|
features: {
|
|
@@ -1500,7 +1700,9 @@ const TwitterApiCreateTweet = ({ text, tweet_Id }) => {
|
|
|
"vibe_api_enabled": true,
|
|
|
"responsive_web_edit_tweet_api_enabled": false,
|
|
|
"standardized_nudges_misinfo": true,
|
|
|
- "responsive_web_enhance_cards_enabled": false
|
|
|
+ "responsive_web_enhance_cards_enabled": false,
|
|
|
+ "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": false,
|
|
|
+ "responsive_web_text_conversations_enabled": false
|
|
|
},
|
|
|
variables: {
|
|
|
"tweet_text": text,
|
|
@@ -1517,7 +1719,8 @@ const TwitterApiCreateTweet = ({ text, tweet_Id }) => {
|
|
|
"dark_request": false
|
|
|
}
|
|
|
};
|
|
|
- axios.post(`https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet`,
|
|
|
+ let url = isMobileTwitter() ? "https://mobile.twitter.com/i/api/graphql/K9It0MijE2UOlX-8wLyPYA/CreateTweet" : "https://twitter.com/i/api/graphql/hC1nuE-2d1NX5LYBuuAvtQ/CreateTweet"
|
|
|
+ axios.post(url,
|
|
|
data, {
|
|
|
headers: {
|
|
|
"accept": "*/*",
|
|
@@ -1536,16 +1739,43 @@ const TwitterApiCreateTweet = ({ text, tweet_Id }) => {
|
|
|
"x-twitter-client-language": "en"
|
|
|
},
|
|
|
}).then(function (response) {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet', task_data: '', task_done: true, response })
|
|
|
+ console.log(response)
|
|
|
+ let data = response.data;
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, iframeId, iframeGUId, response: data, done: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '是', response, iframeId })
|
|
|
+ }
|
|
|
}).catch(function (err) {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet', task_data: '', task_done: false })
|
|
|
+ console.log('err --1', err)
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_CREATE_TWEET_FINISH'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, iframeId, iframeGUId, done: false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'createTweet1', task_data: '', task_done: '否', iframeId })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-export const TwitterApiUserByScreenName = (params) => {
|
|
|
- let { screen_name, tweetId = '', objectType = '' } = params;
|
|
|
- axios.get(`https://twitter.com/i/api/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screen_name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`, {
|
|
|
+const TwitterApiUserByScreenNameReq = (params) => {
|
|
|
+ let { screen_name } = params || {};
|
|
|
+ let url = isMobileTwitter() ? `https://mobile.twitter.com/i/api/graphql/gr8Lk09afdgWo7NvzP89iQ/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screen_name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D` : `https://twitter.com/i/api/graphql/mCbpQvZAw6zu_4PvuAUVVQ/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screen_name}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D`
|
|
|
+ return axios.get(url, {
|
|
|
headers: {
|
|
|
"accept": "*/*",
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
@@ -1562,10 +1792,43 @@ export const TwitterApiUserByScreenName = (params) => {
|
|
|
"x-twitter-auth-type": "OAuth2Session",
|
|
|
"x-twitter-client-language": "en"
|
|
|
},
|
|
|
- }).then(function (response) {
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType }, () => { })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export const TwitterApiUserByScreenName = (params, cb) => {
|
|
|
+ let { screen_name, tweetId = '', objectType = '', iframeId = '', iframeMsg = false, iframeGUId } = params;
|
|
|
+
|
|
|
+ TwitterApiUserByScreenNameReq({ screen_name }).then(function (response) {
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iframeGUId, response: response.data.data || {}, objectType
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: response.data.data || {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
+
|
|
|
}).catch(function (err) {
|
|
|
- chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType }, () => { })
|
|
|
+ if (iframeMsg) {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId,
|
|
|
+ actionType: 'CONTENT_API_GET_TWEET_USER_INFO_END'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ iframeGUId, response: {}, objectType
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "CONTENT_API_GET_TWEET_USER_INFO_RES", data: {}, tweetId, objectType, iframeId }, () => { })
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -1722,7 +1985,7 @@ const initGroupTip = () => {
|
|
|
if (iframe_banner) {
|
|
|
if (twitterAccount != getQueryStringByUrl(iframe_banner.src, 'twitterAccount')) {
|
|
|
iframe_banner.style.display = 'none'
|
|
|
- // iframe_banner.src = chrome.runtime.getURL(`/iframe/group-card.html?twitterAccount=${twitterAccount}`)
|
|
|
+ // iframe_banner.src = chromeExtensionUrl + (`iframe/group-card.html?twitterAccount=${twitterAccount}`)
|
|
|
iframe_banner.contentWindow.postMessage({ actionType: 'SHOW_BANNER', twitterAccount }, '*');
|
|
|
}
|
|
|
return
|
|
@@ -1732,7 +1995,7 @@ const initGroupTip = () => {
|
|
|
let iframe = document.createElement('iframe')
|
|
|
iframe.id = 'denet_group_banner'
|
|
|
iframe.style.cssText = 'border: medium none; display:none; width:100%; height:100px;'
|
|
|
- iframe.src = chrome.runtime.getURL(`/iframe/group-card.html?twitterAccount=${twitterAccount}`)
|
|
|
+ iframe.src = chromeExtensionUrl + (`iframe/group-card.html?twitterAccount=${twitterAccount}`)
|
|
|
// iframe.contentWindow.postMessage({ actionType: 'SHOW_BANNER', twitterAccount }, '*');
|
|
|
if (dom && !dom.parentNode.children[0].querySelector('iframe')) {
|
|
|
// dom.parentNode.insertBefore(iframe, dom)
|
|
@@ -1763,7 +2026,7 @@ export const showBuyNFT = ({ nft_project_Id, post_Id = '' }) => {
|
|
|
}
|
|
|
let iframe = document.querySelector('#nftProjectId')
|
|
|
iframe.style.display = 'block'
|
|
|
- iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html#/?nftProjectId=${nft_project_Id}&postId=${post_Id}`)
|
|
|
+ iframe.src = chromeExtensionUrl + (`iframe/buy-nft.html#/?nftProjectId=${nft_project_Id}&postId=${post_Id}`)
|
|
|
}
|
|
|
|
|
|
const initBuyNFT = () => {
|
|
@@ -1782,7 +2045,7 @@ export const showNFTCard = () => {
|
|
|
let where = isTwitter && userElem && tabIndex;
|
|
|
if (where) {
|
|
|
let iframe = document.createElement('iframe');
|
|
|
- iframe.src = chrome.runtime.getURL(`/iframe/nft-card.html`)
|
|
|
+ iframe.src = chromeExtensionUrl + (`iframe/nft-card.html`)
|
|
|
iframe.style.cssText = 'border:medium none; width:100%; height:290px;';
|
|
|
let nftElement = document.createElement('div');
|
|
|
nftElement.id = 'de-nft-node';
|
|
@@ -1823,7 +2086,7 @@ export const appendPopupPage = (params = {}) => {
|
|
|
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-popup-page';
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/popup-page.html') + `#${path}`;
|
|
|
iframe.style.cssText = `border: medium none; width: 375px !important;
|
|
|
height: 650px;position: fixed; right: 16px; top: 16px;background: #FFFFFF;border: 0.5px solid #919191;box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);box-sizing: border-box;z-index: 90000;
|
|
|
animation-duration: 0.5s !important;
|
|
@@ -1870,7 +2133,7 @@ export const showPopupPage = (params = {}) => {
|
|
|
}
|
|
|
if (iframe) {
|
|
|
if (path) {
|
|
|
- iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
|
|
|
+ iframe.src = chromeExtensionUrl + ('iframe/popup-page.html') + `#${path}`;
|
|
|
}
|
|
|
iframe.style.transform = 'translateX(-' + 395 + 'px)';
|
|
|
|
|
@@ -1985,14 +2248,14 @@ export const setPopupConfByPopupPage = () => {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- * Group Tab List Start
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * Group Tab List Start
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * 创建 Group Tab
|
|
|
+ *
|
|
|
+ * 创建 Group Tab
|
|
|
*/
|
|
|
const createGroupTabNode = () => {
|
|
|
let groupIcon = document.createElement('img');
|
|
@@ -2221,7 +2484,12 @@ const addPageScrollEvent = () => {
|
|
|
contentHeight: contentDom.offsetHeight
|
|
|
}
|
|
|
|
|
|
- messageCenter.send('de-tab-group-content', 'CONTENT_GROUP_LIST_SCROLL', data)
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: 'de-tab-group-content', actionType: 'CONTENT_GROUP_LIST_SCROLL'
|
|
|
+ },
|
|
|
+ data
|
|
|
+ })
|
|
|
|
|
|
// chrome.runtime.sendMessage({
|
|
|
// actionType: "CONTENT_GROUP_LIST_SCROLL",
|
|
@@ -2307,7 +2575,11 @@ const setGroupTabSelfStyle = (params = {}) => {
|
|
|
* 切换到 Group tab时 刷新列表
|
|
|
*/
|
|
|
export const refreshTabGroup = () => {
|
|
|
- messageCenter.send('de-tab-group-content', 'CONTENT_REFRESH_TAB_GROUP_LIST', {})
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: 'de-tab-group-content', actionType: 'CONTENT_REFRESH_TAB_GROUP_LIST'
|
|
|
+ }
|
|
|
+ })
|
|
|
// chrome.runtime.sendMessage({
|
|
|
// actionType: "CONTENT_REFRESH_TAB_GROUP_LIST",
|
|
|
// data: {}
|
|
@@ -2388,7 +2660,7 @@ const addTabGroupContent = (cb) => {
|
|
|
}
|
|
|
let iframe = document.createElement('iframe');
|
|
|
iframe.id = 'de-tab-group-content';
|
|
|
- iframe.src = `${iframeHost}/tab-group` + `?params=${JSON.stringify(params)}`;
|
|
|
+ iframe.src = getInnerIframeURL(`${iframeHost}/tab-group` + `?params=${JSON.stringify(params)}&iframeId=${iframe.id}`);
|
|
|
iframe.style.cssText = `border: medium none; height: 500px;display: none`
|
|
|
|
|
|
let iframeContent = getGroupTabContentNode();
|
|
@@ -2490,7 +2762,9 @@ export const getTweetProfileNavTop = (params) => {
|
|
|
let top = document.querySelector('div[role="tablist"]').closest('nav').getBoundingClientRect().top;
|
|
|
|
|
|
messageCenter.send({
|
|
|
- actionType: "CONTENT_SEND_GROUP_NAV_TOP",
|
|
|
+ info: {
|
|
|
+ actionType: "CONTENT_SEND_GROUP_NAV_TOP"
|
|
|
+ },
|
|
|
data: {
|
|
|
top,
|
|
|
scrollTop: params.scrollTop
|
|
@@ -2534,6 +2808,18 @@ export const setGroupInfo = (params = {}) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export const getExtensionStorgeDataForIframe = (data) => {
|
|
|
+ getChromeStorage(data.key).then((res) => {
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: data.iframeId,
|
|
|
+ actionType: `IFRAME_GET_EXTENSION_STORGE_DATA-${data.messageId}`
|
|
|
+ },
|
|
|
+ data: res
|
|
|
+ })
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
const getSysTheme = () => {
|
|
|
const themeMedia = window.matchMedia("(prefers-color-scheme: light)");
|
|
|
if (themeMedia.matches) {
|
|
@@ -2557,7 +2843,9 @@ const sysThemeChange = () => {
|
|
|
setTimeout(() => {
|
|
|
let bgColor = document.querySelector('body').style.backgroundColor;
|
|
|
messageCenter.send({
|
|
|
- actionType: "CONTENT_SYS_THEME_CHANGE",
|
|
|
+ info: {
|
|
|
+ actionType: "CONTENT_SYS_THEME_CHANGE"
|
|
|
+ },
|
|
|
data: {
|
|
|
theme: systemInfo.theme,
|
|
|
twitterTheme: bgColor == 'rgb(0, 0, 0)' ? 'dark' : 'light'
|
|
@@ -2572,10 +2860,10 @@ const sysThemeChange = () => {
|
|
|
}, 800)
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- * Group Tab List End
|
|
|
- *
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * Group Tab List End
|
|
|
+ *
|
|
|
*/
|
|
|
|
|
|
|
|
@@ -2594,3 +2882,26 @@ export const showPublishDialog = () => {
|
|
|
smallBtn.click();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 获取推文发送回去
|
|
|
+export const sendContentByTwitterID = (params) => {
|
|
|
+ let { tweet_Id, iframeGUId } = JSON.parse(params.data);
|
|
|
+ // 获取内容
|
|
|
+ let txt = parseCard.getContentByTwitterId(tweet_Id);
|
|
|
+ messageCenter.send({
|
|
|
+ info: {
|
|
|
+ iframeId: params.iframeId,
|
|
|
+ actionType: 'CONTENT_GET_TWEET_TXT'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tweet_Id, txt, iframeGUId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 发送
|
|
|
+ // chrome.runtime.sendMessage({
|
|
|
+ // actionType: "CONTENT_GET_TWEET_TXT", data: {
|
|
|
+ // tweet_Id,
|
|
|
+ // txt
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+}
|