|
@@ -126,7 +126,7 @@ export function showPinTips() {
|
|
export function addPinedPop() {
|
|
export function addPinedPop() {
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
let domPop = document.getElementById('de-pin-pop');
|
|
|
|
|
|
- if(domPop) {
|
|
|
|
|
|
+ if (domPop) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,11 +149,11 @@ export function addPinedPop() {
|
|
|
|
|
|
document.querySelector('body').appendChild(popWrapper);
|
|
document.querySelector('body').appendChild(popWrapper);
|
|
|
|
|
|
- document.querySelector('#de-check').onclick = function() {
|
|
|
|
- setChromeStorage({ pinData: JSON.stringify({show: !this.checked}) })
|
|
|
|
|
|
+ document.querySelector('#de-check').onclick = function () {
|
|
|
|
+ setChromeStorage({ pinData: JSON.stringify({ show: !this.checked }) })
|
|
}
|
|
}
|
|
|
|
|
|
- document.querySelector('.de-pin-skip').onclick = function() {
|
|
|
|
|
|
+ document.querySelector('.de-pin-skip').onclick = function () {
|
|
document.querySelector('#de-pin-pop').style.display = 'none';
|
|
document.querySelector('#de-pin-pop').style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -282,7 +282,7 @@ function _addIframe() {
|
|
// document.body.appendChild(span)
|
|
// document.body.appendChild(span)
|
|
dom.iframe = iframe;
|
|
dom.iframe = iframe;
|
|
let iframeContent = document.getElementById('iframe-content');
|
|
let iframeContent = document.getElementById('iframe-content');
|
|
- if(!iframeContent) {
|
|
|
|
|
|
+ if (!iframeContent) {
|
|
document.getElementById('layers').appendChild(iframe);
|
|
document.getElementById('layers').appendChild(iframe);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -358,11 +358,11 @@ function _setPublishContent(content) {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
// document.execCommand('selectAll')
|
|
// document.execCommand('selectAll')
|
|
// document.execCommand("Delete","false",null);
|
|
// document.execCommand("Delete","false",null);
|
|
- if(!isSetContent) {
|
|
|
|
|
|
+ if (!isSetContent) {
|
|
isSetContent = true;
|
|
isSetContent = true;
|
|
document.execCommand("insertText", false, content);
|
|
document.execCommand("insertText", false, content);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}, 1000);
|
|
}, 1000);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -479,18 +479,18 @@ function checkHasDeBtn() {
|
|
/**
|
|
/**
|
|
* 根据postID绑定推文id
|
|
* 根据postID绑定推文id
|
|
*/
|
|
*/
|
|
- function bindTwitterArtMethod({postId, twitterId}) {
|
|
|
|
|
|
+function bindTwitterArtMethod({ postId, twitterId }) {
|
|
let regex = new RegExp(bindTwitterArt.postId);
|
|
let regex = new RegExp(bindTwitterArt.postId);
|
|
if (regex.test(postId)) {
|
|
if (regex.test(postId)) {
|
|
if (twitterId && bindTwitterArt.needBind && !bindTwitterArt.isBindIng) {
|
|
if (twitterId && bindTwitterArt.needBind && !bindTwitterArt.isBindIng) {
|
|
bindTwitterArt.isBindIng = true;
|
|
bindTwitterArt.isBindIng = true;
|
|
srcPublishSuccess({
|
|
srcPublishSuccess({
|
|
- params: {
|
|
|
|
|
|
+ params: {
|
|
postId: postId,
|
|
postId: postId,
|
|
srcContentId: twitterId
|
|
srcContentId: twitterId
|
|
}
|
|
}
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
- if(res.code == 0) {
|
|
|
|
|
|
+ if (res.code == 0) {
|
|
bindTwitterArt.needBind = false;
|
|
bindTwitterArt.needBind = false;
|
|
bindTwitterArt.postId = '';
|
|
bindTwitterArt.postId = '';
|
|
bindTwitterArt.isBindIng = false;
|
|
bindTwitterArt.isBindIng = false;
|
|
@@ -506,7 +506,7 @@ function parseDOMRedPacket() {
|
|
let _type = ''
|
|
let _type = ''
|
|
for (let i in arr) {
|
|
for (let i in arr) {
|
|
if (arr[i].innerText == '#DeNet') {
|
|
if (arr[i].innerText == '#DeNet') {
|
|
- let _tweetId = ''
|
|
|
|
|
|
+ let _tweetId = ''
|
|
let _article = arr[i].closest('article')
|
|
let _article = arr[i].closest('article')
|
|
let _txt_area = _article.querySelector('[lang]')
|
|
let _txt_area = _article.querySelector('[lang]')
|
|
let _postId = _txt_area.innerText
|
|
let _postId = _txt_area.innerText
|
|
@@ -519,10 +519,10 @@ function parseDOMRedPacket() {
|
|
_dom = _txt_area.parentNode.parentNode
|
|
_dom = _txt_area.parentNode.parentNode
|
|
}
|
|
}
|
|
let _a_area = _article.querySelector('a[aria-label]')
|
|
let _a_area = _article.querySelector('a[aria-label]')
|
|
- if(_a_area && _a_area.getAttribute('href')){
|
|
|
|
|
|
+ if (_a_area && _a_area.getAttribute('href')) {
|
|
_tweetId = _a_area.getAttribute('href').split('/status/')[1] || ''
|
|
_tweetId = _a_area.getAttribute('href').split('/status/')[1] || ''
|
|
- if(bindTwitterArt.needBind) {
|
|
|
|
- bindTwitterArtMethod({postId: _postId, twitterId: _tweetId});
|
|
|
|
|
|
+ if (bindTwitterArt.needBind) {
|
|
|
|
+ bindTwitterArtMethod({ postId: _postId, twitterId: _tweetId });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
replaceDOMRedPacket(_type, _dom, _postId, _tweetId)
|
|
replaceDOMRedPacket(_type, _dom, _postId, _tweetId)
|
|
@@ -530,7 +530,7 @@ function parseDOMRedPacket() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function createIframe(postId,tweetId) {
|
|
|
|
|
|
+function createIframe(postId, tweetId) {
|
|
let _iframe = document.createElement('iframe')
|
|
let _iframe = document.createElement('iframe')
|
|
_iframe.id = postId
|
|
_iframe.id = postId
|
|
_iframe.src = chrome.runtime.getURL('/iframe/red-packet.html') + `?postId=${postId}&tweetId=${tweetId}`;
|
|
_iframe.src = chrome.runtime.getURL('/iframe/red-packet.html') + `?postId=${postId}&tweetId=${tweetId}`;
|
|
@@ -538,7 +538,14 @@ function createIframe(postId,tweetId) {
|
|
return _iframe
|
|
return _iframe
|
|
}
|
|
}
|
|
function replaceDOMRedPacket(_type, _dom, postId, tweetId) {
|
|
function replaceDOMRedPacket(_type, _dom, postId, tweetId) {
|
|
- if (!_dom || _dom.querySelector('iframe')) {
|
|
|
|
|
|
+ if (!_dom) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let _dom_iframe = _dom.querySelectorAll('iframe')
|
|
|
|
+ if (_dom_iframe.length > 0) {
|
|
|
|
+ if (_dom_iframe.length > 1) {
|
|
|
|
+ _dom_iframe[1].remove()
|
|
|
|
+ }
|
|
return
|
|
return
|
|
}
|
|
}
|
|
let _len
|
|
let _len
|
|
@@ -548,9 +555,9 @@ function replaceDOMRedPacket(_type, _dom, postId, tweetId) {
|
|
_dom.children[i].style.display = 'none'
|
|
_dom.children[i].style.display = 'none'
|
|
}
|
|
}
|
|
_dom.style = 'height:500px'
|
|
_dom.style = 'height:500px'
|
|
- _dom.appendChild(createIframe(postId,tweetId))
|
|
|
|
|
|
+ _dom.appendChild(createIframe(postId, tweetId))
|
|
} else {
|
|
} else {
|
|
- _dom.insertBefore(createIframe(postId,tweetId), _dom.children[1])
|
|
|
|
|
|
+ _dom.insertBefore(createIframe(postId, tweetId), _dom.children[1])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|