|
@@ -1,3 +1,4 @@
|
|
|
+import { parseAllDeNetCardParmas, getCardParmas } from './ParseCard';
|
|
|
const addDom = () => {
|
|
|
window.parseAllDeNetCard = () => {
|
|
|
let de_net_card = [];
|
|
@@ -46,17 +47,17 @@ const addDom = () => {
|
|
|
}
|
|
|
return { tweet_Id, short_url, dom_card };
|
|
|
};
|
|
|
- window.parseAllDeNetCardParmas = () => {
|
|
|
- let json_data = [];
|
|
|
- window.parseAllDeNetCard().forEach(item => {
|
|
|
- let _obj = window.parseCardParmas(item.dom);
|
|
|
- if (_obj.tweet_Id && _obj.short_url && _obj.dom_card) {
|
|
|
- _obj.time = item.time;
|
|
|
- json_data.push(_obj);
|
|
|
- }
|
|
|
- });
|
|
|
- return json_data;
|
|
|
- };
|
|
|
+ // window.parseAllDeNetCardParmas = () => {
|
|
|
+ // let json_data = [];
|
|
|
+ // window.parseAllDeNetCard().forEach(item => {
|
|
|
+ // let _obj = window.parseCardParmas(item.dom);
|
|
|
+ // if (_obj.tweet_Id && _obj.short_url && _obj.dom_card) {
|
|
|
+ // _obj.time = item.time;
|
|
|
+ // json_data.push(_obj);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // return json_data;
|
|
|
+ // };
|
|
|
window.toRedpackPage = ({ post_Id, tweet_Id }) => {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
JSON.stringify({
|
|
@@ -158,29 +159,121 @@ const addDom = () => {
|
|
|
});
|
|
|
div.id = 'denet-card';
|
|
|
div.style.color = 'red';
|
|
|
- div.innerHTML = `
|
|
|
- <h2>这里是自定义插入的内容</h2>
|
|
|
- tweet_Id:${tweet_Id} ,
|
|
|
- post_Id:${post_Id}
|
|
|
- 获取dom时间:${time}
|
|
|
- 短链接:${short_url}<img onclick="toRedpackPage()" src="https://pbs.twimg.com/card_img/1559498011880804353/yV6kTKyQ?format=jpg&name=small" style="width: 100%"/>
|
|
|
- 渲染时长:${(new Date().getTime() - time) / 1000}s
|
|
|
- `;
|
|
|
+ // div.innerHTML = `
|
|
|
+ // <h2>这里是自定义插入的内容</h2>
|
|
|
+ // tweet_Id:${tweet_Id} ,
|
|
|
+ // post_Id:${post_Id}
|
|
|
+ // 获取dom时间:${time}
|
|
|
+ // 短链接:${short_url}<img onclick="toRedpackPage()" src="https://pbs.twimg.com/card_img/1559498011880804353/yV6kTKyQ?format=jpg&name=small" style="width: 100%"/>
|
|
|
+ // 渲染时长:${(new Date().getTime() - time) / 1000}s
|
|
|
+ // `;
|
|
|
dom.appendChild(div);
|
|
|
// window.TwitterLikeAPI(1559235463868710917);
|
|
|
|
|
|
// dom.appendChild(this.createIframe({post_Id, tweet_Id, page_type}));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ let queue_num = 1;
|
|
|
+
|
|
|
+ const changeQueueNum = (num = 0) => {
|
|
|
+ queue_num = queue_num + num;
|
|
|
+ if (queue_num > 5) {
|
|
|
+ queue_num = 5;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
try {
|
|
|
let timer = setInterval(() => {
|
|
|
- let card_json_data = window.parseAllDeNetCardParmas();
|
|
|
- if (card_json_data.length) {
|
|
|
- clearInterval(timer);
|
|
|
- for (let i = 0; i < card_json_data.length; i++) {
|
|
|
- replaceDOMRedPacket(card_json_data[i]);
|
|
|
- }
|
|
|
- }
|
|
|
+ let card_json_data = parseAllDeNetCardParmas();
|
|
|
+ getCardParmas(card_json_data).then(res => {
|
|
|
+ console.log('res', 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;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 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 (res.need_net_short_urls.length > 0) {
|
|
|
+ // parseCard.netShortUrl(res.need_net_short_urls, () => {
|
|
|
+ // changeQueueNum(5);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ });
|
|
|
}, 1000);
|
|
|
|
|
|
// let contain = document.getElementsByTagName('body')[0];
|
|
@@ -197,45 +290,4 @@ const addDom = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const TwitterLikeAPI = tweet_Id => {
|
|
|
- alert(tweet_Id);
|
|
|
- fetch(
|
|
|
- 'https://mobile.twitter.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet',
|
|
|
- {
|
|
|
- headers: {
|
|
|
- accept: '*/*',
|
|
|
- 'accept-language': 'zh-CN,zh;q=0.9',
|
|
|
- authorization:
|
|
|
- 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
|
|
|
- 'cache-control': 'no-cache',
|
|
|
- 'content-type': 'application/json',
|
|
|
- pragma: 'no-cache',
|
|
|
- 'sec-fetch-dest': 'document',
|
|
|
- 'sec-fetch-mode': 'cors',
|
|
|
- 'sec-fetch-site': 'same-origin',
|
|
|
- 'x-csrf-token': window.getCookie('ct0'),
|
|
|
- 'x-twitter-active-user': 'yes',
|
|
|
- 'x-twitter-auth-type': 'OAuth2Session',
|
|
|
- 'x-twitter-client-language': 'zh-cn',
|
|
|
- },
|
|
|
- referrer: 'https://mobile.twitter.com',
|
|
|
- referrerPolicy: 'strict-origin-when-cross-origin',
|
|
|
- body: `{"variables":{"tweet_id":"
|
|
|
- ${tweet_Id}
|
|
|
- "},"queryId":"lI07N6Otwv1PhnEgXILM7A"}`,
|
|
|
- method: 'POST',
|
|
|
- mode: 'cors',
|
|
|
- credentials: 'include',
|
|
|
- },
|
|
|
- )
|
|
|
- .then(res => {
|
|
|
- console.log(res);
|
|
|
- alert(JSON.stringify(res));
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- // alert(window.getCookie('ct0'))
|
|
|
- // alert(e);
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
-export { addDom, TwitterLikeAPI };
|
|
|
+export { addDom };
|