|
@@ -1,5 +1,5 @@
|
|
|
import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
|
|
|
-import { throttle, getQueryString } from '@/uilts/help'
|
|
|
+import { throttle, getQueryString, getCookie } from '@/uilts/help'
|
|
|
import { discordAuthRedirectUri } from '@/http/configAPI'
|
|
|
import { reportSrcPublishEvent } from '@/http/publishApi'
|
|
|
import Report from "@/log-center/log"
|
|
@@ -75,7 +75,7 @@ export function hideIframeHandler() {
|
|
|
|
|
|
export function showTwitterPublishDialogHandler(publishRes) {
|
|
|
let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
|
|
|
- if(bigBtn) {
|
|
|
+ if (bigBtn) {
|
|
|
bigBtn.click();
|
|
|
} else {
|
|
|
let smallBtn = document.querySelector('a[href="/compose/tweet"]')
|
|
@@ -179,8 +179,8 @@ function _publishTweetEvent(params, cb) {
|
|
|
|
|
|
function checkIsShowReSend(dom, params) {
|
|
|
let str = dom.querySelector('div[data-contents="true"]').innerHTML;
|
|
|
- if(str.indexOf('#DeNet') < 0 || str.indexOf(params.postId) < 0) {
|
|
|
- noticeBindTweet({postId: params.postId, taskLuckdropId: ''});
|
|
|
+ if (str.indexOf('#DeNet') < 0 || str.indexOf(params.postId) < 0) {
|
|
|
+ noticeBindTweet({ postId: params.postId, taskLuckdropId: '' });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -296,11 +296,11 @@ function _addIframe() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function addPublishTipsIframe({srcContent}) {
|
|
|
+function addPublishTipsIframe({ srcContent }) {
|
|
|
setTimeout(() => {
|
|
|
let dialog = document.querySelector('div[role="dialog"]').querySelector('div[role="dialog"]')
|
|
|
|
|
|
- if(dialog) {
|
|
|
+ if (dialog) {
|
|
|
let right = dialog.offsetLeft - 15 - 266, top = window.innerHeight * 0.05 + dialog.offsetHeight - 60 - 160;
|
|
|
|
|
|
let iframe = document.createElement('iframe');
|
|
@@ -308,7 +308,7 @@ function addPublishTipsIframe({srcContent}) {
|
|
|
iframe.src = chrome.runtime.getURL('/iframe/publish-tips.html');
|
|
|
iframe.style.cssText = `border: medium none; width:266px;min-height:178px;position: fixed; right: ${right}px; top: ${top}px;`
|
|
|
let iframeContent = document.getElementById('de-publish-tips');
|
|
|
- if(!iframeContent) {
|
|
|
+ if (!iframeContent) {
|
|
|
dialog.appendChild(iframe)
|
|
|
}
|
|
|
}
|
|
@@ -321,14 +321,14 @@ export function noticeBindTweet(params) {
|
|
|
iframe.src = chrome.runtime.getURL('/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;`
|
|
|
let iframeContent = document.getElementById('de-notice-bind-tweet');
|
|
|
- if(!iframeContent) {
|
|
|
+ if (!iframeContent) {
|
|
|
document.querySelector('body').appendChild(iframe)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function hideNoticeBindTweet() {
|
|
|
let iframeContent = document.getElementById('de-notice-bind-tweet');
|
|
|
- if(iframeContent) {
|
|
|
+ if (iframeContent) {
|
|
|
document.querySelector('body').removeChild(iframeContent)
|
|
|
}
|
|
|
}
|
|
@@ -599,7 +599,7 @@ function onChangePageMain(targetNode) {
|
|
|
function setIframeRedPacket(type = 'twitter') {
|
|
|
|
|
|
let card_json_data
|
|
|
- switch(type) {
|
|
|
+ switch (type) {
|
|
|
case 'facebook':
|
|
|
card_json_data = parseCard.parseFacebookCardParmas()
|
|
|
for (let i in card_json_data) {
|
|
@@ -663,7 +663,7 @@ export function init() {
|
|
|
}
|
|
|
twitterPinLogin();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
let timer = setInterval(() => {
|
|
|
let inTwitter = window.location.href.includes('twitter.com');
|
|
|
let inTwitterNode = document.querySelector('main');
|
|
@@ -721,13 +721,13 @@ export function init() {
|
|
|
}
|
|
|
|
|
|
export function facebookReplyTweet(params) {
|
|
|
- if(window.location.origin.indexOf('twitter.com')) {
|
|
|
+ if (window.location.origin.indexOf('twitter.com')) {
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
const actionType = urlParams.get('actionType');
|
|
|
let deReplyParams = urlParams.get('deReplyParams') || '{}';
|
|
|
deReplyParams = JSON.parse(deReplyParams);
|
|
|
if (actionType == 'denetFacebookToTwitterReply') {
|
|
|
- if(params.postId == deReplyParams.postId) {
|
|
|
+ if (params.postId == deReplyParams.postId) {
|
|
|
let iframe = document.getElementById(params.postId);
|
|
|
iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_FACEBOOK_REPLY', data: deReplyParams }, '*');
|
|
|
}
|
|
@@ -737,33 +737,33 @@ export function facebookReplyTweet(params) {
|
|
|
|
|
|
export function replyHandle(params) {
|
|
|
let iframe = window.parent.document.getElementById(params.postId);
|
|
|
- let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
- iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
- if(replyBtn) {
|
|
|
+ let replyBtn = iframe.parentNode.parentNode.querySelector('div[data-testid="reply"]') ||
|
|
|
+ iframe.parentNode.parentNode.parentNode.querySelector('div[data-testid="reply"]');
|
|
|
+ if (replyBtn) {
|
|
|
replyBtn.click();
|
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
|
|
let dialog = document.querySelector('div[role="dialog"]');
|
|
|
- if(dialog) {
|
|
|
+ if (dialog) {
|
|
|
let replyBtn = dialog.querySelector('div[data-testid="toolBar"]').querySelector('div[data-testid="tweetButton"]');
|
|
|
- replyBtn.addEventListener('click', function() {
|
|
|
+ replyBtn.addEventListener('click', function () {
|
|
|
let eleList = dialog.querySelector('div[contenteditable="true"]').querySelectorAll('span[data-text="true"]');
|
|
|
- if(eleList && eleList.length) {
|
|
|
+ if (eleList && eleList.length) {
|
|
|
let atList = [];
|
|
|
- for(let i = 0; i < eleList.length; i++) {
|
|
|
+ for (let i = 0; i < eleList.length; i++) {
|
|
|
let item = eleList[i];
|
|
|
|
|
|
- let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
|
|
|
+ let reg = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g;
|
|
|
|
|
|
- if(item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
|
|
|
+ if (item && item.innerText.startsWith('@') && !reg.test(item.innerText)) {
|
|
|
atList.push({
|
|
|
text: item.innerText
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(atList.length >= 3) {
|
|
|
+ if (atList.length >= 3) {
|
|
|
fetchAddFinishEvent({
|
|
|
eventType: params.type,
|
|
|
luckdropId: params.taskLuckdropId
|
|
@@ -889,18 +889,127 @@ export function getTweetAuthorByDom(params) {
|
|
|
let iframe = document.getElementById(params.postId);
|
|
|
let fullNameDom;
|
|
|
let pathNameArr = window.location.pathname.split('/');
|
|
|
- if(pathNameArr.length >= 2 && pathNameArr[pathNameArr.length - 2] == 'status') {
|
|
|
+ if (pathNameArr.length >= 2 && pathNameArr[pathNameArr.length - 2] == 'status') {
|
|
|
fullNameDom = iframe.parentNode.parentNode.parentNode.parentNode.querySelector('a[role=link]');
|
|
|
} else {
|
|
|
fullNameDom = iframe.parentNode.parentNode.parentNode.querySelector('a[role=link]');
|
|
|
}
|
|
|
- if(fullNameDom) {
|
|
|
+ if (fullNameDom) {
|
|
|
let arr = fullNameDom.href.split('/');
|
|
|
- if(arr.length) {
|
|
|
- let fullName = arr[arr.length-1];
|
|
|
- if(fullName) {
|
|
|
- iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_GET_TWEET_AUTHOR', data: {fullName} }, '*');
|
|
|
+ if (arr.length) {
|
|
|
+ let fullName = arr[arr.length - 1];
|
|
|
+ if (fullName) {
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_RED_PACKET_GET_TWEET_AUTHOR', data: { fullName } }, '*');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+export function doTaskTwitterAPI({ task_data, task_type }) {
|
|
|
+ switch (task_type) {
|
|
|
+ case 'like':
|
|
|
+ TwitterLikeAPI(task_data.tweet_Id)
|
|
|
+ break
|
|
|
+ case 'retweet':
|
|
|
+ TwitterRetweetAPI(task_data.tweet_Id)
|
|
|
+ break
|
|
|
+ case 'follow':
|
|
|
+ task_data.follow_data.forEach((item) => {
|
|
|
+ if (item.name && item.twitterUserId) {
|
|
|
+ TwitterFollowAPI(item, task_data.tweet_Id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const TwitterFollowAPI = (item, tweet_Id) => {
|
|
|
+ fetch("https://twitter.com/i/api/1.1/friendships/create.json", {
|
|
|
+ "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": "zh-cn"
|
|
|
+ },
|
|
|
+ "referrer": "https://twitter.com/home",
|
|
|
+ "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&user_id=" + item.twitterUserId + "",
|
|
|
+ "method": "POST",
|
|
|
+ "mode": "cors",
|
|
|
+ "credentials": "include"
|
|
|
+ }).then(() => {
|
|
|
+ let task_data = {
|
|
|
+ follow_name: item.name
|
|
|
+ }
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'follow', task_data, task_done: true }, () => { })
|
|
|
+ }).catch(() => {
|
|
|
+ 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", {
|
|
|
+ "headers": {
|
|
|
+ "accept": "*/*",
|
|
|
+ "accept-language": "zh,en;q=0.9,zh-CN;q=0.8",
|
|
|
+ "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
+ "content-type": "application/json",
|
|
|
+ "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\"",
|
|
|
+ "sec-fetch-dest": "empty",
|
|
|
+ "sec-fetch-mode": "cors",
|
|
|
+ "sec-fetch-site": "same-origin",
|
|
|
+ "x-csrf-token": getCookie('ct0'),
|
|
|
+ "x-twitter-active-user": "yes",
|
|
|
+ "x-twitter-auth-type": "OAuth2Session",
|
|
|
+ "x-twitter-client-language": "zh-cn"
|
|
|
+ },
|
|
|
+ "referrer": "https://twitter.com/home",
|
|
|
+ "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
+ "body": "{\"variables\":{\"tweet_id\":\"" + tweet_Id + "\",\"dark_request\":false},\"queryId\":\"ojPdsZsimiJrUGLR1sjUtA\"}",
|
|
|
+ "method": "POST",
|
|
|
+ "mode": "cors",
|
|
|
+ "credentials": "include"
|
|
|
+ }).then(() => {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'retweet', task_data: '', task_done: true }, () => { })
|
|
|
+ }).catch(() => {
|
|
|
+ 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", {
|
|
|
+ "headers": {
|
|
|
+ "accept": "*/*",
|
|
|
+ "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
|
+ "authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
|
|
|
+ "content-type": "application/json",
|
|
|
+ "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"",
|
|
|
+ "sec-ch-ua-mobile": "?0",
|
|
|
+ "sec-ch-ua-platform": "\"Windows\"",
|
|
|
+ "sec-fetch-dest": "empty",
|
|
|
+ "sec-fetch-mode": "cors",
|
|
|
+ "sec-fetch-site": "same-origin",
|
|
|
+ "x-csrf-token": getCookie('ct0'),
|
|
|
+ "x-twitter-active-user": "yes",
|
|
|
+ "x-twitter-auth-type": "OAuth2Session",
|
|
|
+ "x-twitter-client-language": "en"
|
|
|
+ },
|
|
|
+ "referrer": "https://twitter.com/home",
|
|
|
+ "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
+ "body": "{\"variables\":{\"tweet_id\":\"" + tweet_Id + "\"},\"queryId\":\"lI07N6Otwv1PhnEgXILM7A\"}",
|
|
|
+ "method": "POST",
|
|
|
+ "mode": "cors",
|
|
|
+ "credentials": "include"
|
|
|
+ }).then(() => {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: true }, () => { })
|
|
|
+ }).catch(() => {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", do_type: 'api', tweet_Id, task_type: 'like', task_data: '', task_done: false }, () => { })
|
|
|
+ })
|
|
|
}
|