|
@@ -41,13 +41,38 @@ export function backTwitterPinLoginCode(code) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- // 发送请求
|
|
|
- // token,code
|
|
|
- twitterLogin(authToken, code).then(res => {
|
|
|
- if (res.code == 0) {
|
|
|
- setChromeStorage({ userInfo: JSON.stringify(res.data) })
|
|
|
+ chrome.cookies.getAll(
|
|
|
+ {
|
|
|
+ name: 'received_log',
|
|
|
+ url: 'http:localhost:3000'
|
|
|
+ }, (e = []) => {
|
|
|
+ let _str = '[]'
|
|
|
+ if (e.length > 0) {
|
|
|
+ _str = e[0].value
|
|
|
+ }
|
|
|
+ let _arr = JSON.parse(decodeURIComponent(_str))
|
|
|
+ let receivedIds = []
|
|
|
+ if (_arr.length > 0) {
|
|
|
+ for (let i in _arr) {
|
|
|
+ receivedIds.push(_arr[i].receivedId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 发送请求
|
|
|
+ // token,code
|
|
|
+ twitterLogin(authToken, code, receivedIds).then(res => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ setChromeStorage({ userInfo: JSON.stringify(res.data) })
|
|
|
+ // chrome.cookies.remove(
|
|
|
+ // {
|
|
|
+ // name: 'received_log',
|
|
|
+ // url: 'http:localhost:3000'
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -86,8 +111,8 @@ export function hideIframeHandler() {
|
|
|
export function showTwitterPublishDialogHandler(publishRes) {
|
|
|
dom.tweetBtn.click();
|
|
|
_setPublishContent(publishRes.srcContent);
|
|
|
- _publishTweetEvent(publishRes.postId ,(twitterArtId) => {
|
|
|
- if(twitterArtId) {
|
|
|
+ _publishTweetEvent(publishRes.postId, (twitterArtId) => {
|
|
|
+ if (twitterArtId) {
|
|
|
getUserInfo((userInfo) => {
|
|
|
if (userInfo) {
|
|
|
srcPublishSuccess({
|
|
@@ -235,15 +260,15 @@ function _getTwitterArtId(contentStr, cb) {
|
|
|
|
|
|
let timer = setInterval(() => {
|
|
|
let artDomList = document.querySelectorAll('article[data-testid="tweet"]');
|
|
|
- for(let i = 0; i < artDomList.length; i++) {
|
|
|
+ for (let i = 0; i < artDomList.length; i++) {
|
|
|
let itemChild = artDomList[i].querySelector('.css-1dbjc4n');
|
|
|
- if(itemChild && itemChild.querySelector('div[lang="und"]')) {
|
|
|
+ if (itemChild && itemChild.querySelector('div[lang="und"]')) {
|
|
|
let innerText = itemChild.querySelector('div[lang="und"]').innerText;
|
|
|
let regex = new RegExp(contentStr);
|
|
|
- if(regex.test(innerText)) {
|
|
|
+ if (regex.test(innerText)) {
|
|
|
id = itemChild.parentNode.querySelector('a[dir="auto"]').getAttribute('href').split('/status/')[1];
|
|
|
clearInterval(timer);
|
|
|
- if(id) {
|
|
|
+ if (id) {
|
|
|
cb && cb(id);
|
|
|
}
|
|
|
break;
|
|
@@ -301,11 +326,11 @@ function _createBtnDom(port) {
|
|
|
shadowRoot.appendChild(shadowDiv);
|
|
|
|
|
|
const deBtn1 = document.createElement('img');
|
|
|
- let src = require( "../assets/img/icon-gift-pack.png");
|
|
|
+ let src = require("../assets/img/icon-gift-pack.png");
|
|
|
const smallDeBtnStyle = 'width:20px;height: 20px;cursor: pointer;marign-left:4px;margin-right:4px';
|
|
|
deBtn1.id = 'de-btn1';
|
|
|
deBtn1.style.cssText = smallDeBtnStyle;
|
|
|
- deBtn1.src =src
|
|
|
+ deBtn1.src = src
|
|
|
|
|
|
const deBtn2 = document.createElement('div');
|
|
|
deBtn2.id = 'de-btn2';
|
|
@@ -374,12 +399,12 @@ function replaceDOMRedPacket(_dom, postId) {
|
|
|
if (!_dom || _dom.parentNode.parentNode.querySelector('iframe')) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// _dom.parentNode.parentNode.children[0].innerHTML
|
|
|
_dom.parentNode.parentNode.children[1].innerHTML = ''
|
|
|
let _iframe = document.createElement('iframe')
|
|
|
_iframe.id = postId
|
|
|
- _iframe.src = chrome.runtime.getURL('/iframe/red-packet.html') + '?postId='+postId;
|
|
|
+ _iframe.src = chrome.runtime.getURL('/iframe/red-packet.html') + '?postId=' + postId;
|
|
|
_iframe.style.cssText = 'border: medium none; width:375px;height:500px;'
|
|
|
_dom.parentNode.parentNode.children[1].style = 'height:500px'
|
|
|
_dom.parentNode.parentNode.children[1].appendChild(_iframe)
|
|
@@ -393,17 +418,16 @@ export function setIframeRedPacket() {
|
|
|
// return
|
|
|
// }
|
|
|
parseDOMRedPacket()
|
|
|
- let _current_top = 0
|
|
|
-
|
|
|
- // setInterval(() => {
|
|
|
- // parseDOMRedPacket()
|
|
|
- // }, 1000)
|
|
|
- document.addEventListener('scroll', (e) => {
|
|
|
- if ((elment.scrollTop - _current_top) > 500 || (_current_top - elment.scrollTop) > 500) {
|
|
|
- _current_top = elment.scrollTop
|
|
|
- // 1.解析推文
|
|
|
- // 2.替换推文
|
|
|
+ // let _current_top = 0
|
|
|
+ setInterval(() => {
|
|
|
parseDOMRedPacket()
|
|
|
- }
|
|
|
- })
|
|
|
+ }, 1000)
|
|
|
+ // document.addEventListener('scroll', (e) => {
|
|
|
+ // if ((elment.scrollTop - _current_top) > 500 || (_current_top - elment.scrollTop) > 500) {
|
|
|
+ // _current_top = elment.scrollTop
|
|
|
+ // 1.解析推文
|
|
|
+ // 2.替换推文
|
|
|
+ // parseDOMRedPacket()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|