|
@@ -72,6 +72,7 @@ export function backHttpTwitterShortUrl(url) {
|
|
httpTwitterShortUrl(url).then(res => {
|
|
httpTwitterShortUrl(url).then(res => {
|
|
let _str_arr = res.match(/denetme.net\/([\s\S]*?)"/) || []
|
|
let _str_arr = res.match(/denetme.net\/([\s\S]*?)"/) || []
|
|
let _post_id = _str_arr[1] || ''
|
|
let _post_id = _str_arr[1] || ''
|
|
|
|
+ console.log('_str_arr_post_id', _post_id)
|
|
if (!_post_id) {
|
|
if (!_post_id) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -221,13 +222,13 @@ function _publishTweetEvent(contentStr, cb) {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
let publishTweetBtn;
|
|
let publishTweetBtn;
|
|
let dialog = document.querySelector('div[role="dialog"]');
|
|
let dialog = document.querySelector('div[role="dialog"]');
|
|
- if(dialog) {
|
|
|
|
|
|
+ if (dialog) {
|
|
publishTweetBtn = dialog.querySelector('div[data-testid="tweetButton"]');
|
|
publishTweetBtn = dialog.querySelector('div[data-testid="tweetButton"]');
|
|
} else {
|
|
} else {
|
|
- let domMain = document.querySelector('main[role="main"]');
|
|
|
|
|
|
+ let domMain = document.querySelector('main[role="main"]');
|
|
publishTweetBtn = domMain && domMain.querySelector('div[data-testid="tweetButton"]');
|
|
publishTweetBtn = domMain && domMain.querySelector('div[data-testid="tweetButton"]');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
publishTweetBtn && publishTweetBtn.addEventListener('click', function () {
|
|
publishTweetBtn && publishTweetBtn.addEventListener('click', function () {
|
|
bindTwitterArt.needBind = true;
|
|
bindTwitterArt.needBind = true;
|
|
bindTwitterArt.postId = contentStr;
|
|
bindTwitterArt.postId = contentStr;
|
|
@@ -255,7 +256,7 @@ function _addDeNetEditBtn(parent, dom, isClick = false) {
|
|
} else {
|
|
} else {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
parent = _getScheduleDom(isClick);
|
|
parent = _getScheduleDom(isClick);
|
|
- if(parent && parent.parentNode) {
|
|
|
|
|
|
+ if (parent && parent.parentNode) {
|
|
Report.reportLog({
|
|
Report.reportLog({
|
|
pageSource: Report.pageSource.mainPage,
|
|
pageSource: Report.pageSource.mainPage,
|
|
businessType: Report.businessType.buttonView,
|
|
businessType: Report.businessType.buttonView,
|
|
@@ -583,7 +584,7 @@ function bindTwitterArtMethod({ postId, twitterId }) {
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
Report.reportLog({
|
|
Report.reportLog({
|
|
objectType: Report.objectType.tweetPostBinded
|
|
objectType: Report.objectType.tweetPostBinded
|
|
- });
|
|
|
|
|
|
+ });
|
|
bindTwitterArt.needBind = false;
|
|
bindTwitterArt.needBind = false;
|
|
bindTwitterArt.postId = '';
|
|
bindTwitterArt.postId = '';
|
|
bindTwitterArt.isBindIng = false;
|
|
bindTwitterArt.isBindIng = false;
|
|
@@ -626,12 +627,12 @@ function parseDOMRedPacket() {
|
|
let parse_dom = {}
|
|
let parse_dom = {}
|
|
|
|
|
|
async function parseDOMRedPacketByShortUrl(port) {
|
|
async function parseDOMRedPacketByShortUrl(port) {
|
|
- let _new_time = new Date().getTime()
|
|
|
|
- if ((_new_time - change_time) > 1000) {
|
|
|
|
- change_time = _new_time
|
|
|
|
- } else {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ // let _new_time = new Date().getTime()
|
|
|
|
+ // if ((_new_time - change_time) > 1000) {
|
|
|
|
+ // change_time = _new_time
|
|
|
|
+ // } else {
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
// 为了减少声明变量次数
|
|
// 为了减少声明变量次数
|
|
parse_dom.dom = null
|
|
parse_dom.dom = null
|
|
parse_dom.txt_area = null
|
|
parse_dom.txt_area = null
|
|
@@ -661,8 +662,12 @@ async function parseDOMRedPacketByShortUrl(port) {
|
|
}
|
|
}
|
|
parse_dom.postId = await handleShortUrl(port, parse_dom.short_url)
|
|
parse_dom.postId = await handleShortUrl(port, parse_dom.short_url)
|
|
console.log('_postId', parse_dom.postId)
|
|
console.log('_postId', parse_dom.postId)
|
|
|
|
+ console.log('short_url', parse_dom.short_url)
|
|
|
|
+
|
|
// 获取到postId了
|
|
// 获取到postId了
|
|
if (parse_dom.postId) {
|
|
if (parse_dom.postId) {
|
|
|
|
+ console.log('bindTwitterArt.postId', bindTwitterArt.postId)
|
|
|
|
+ console.log('parse_dom.postId', parse_dom.postId)
|
|
if (bindTwitterArt.needBind) {
|
|
if (bindTwitterArt.needBind) {
|
|
bindTwitterArtMethod({ postId: parse_dom.postId, twitterId: parse_dom.tweetId });
|
|
bindTwitterArtMethod({ postId: parse_dom.postId, twitterId: parse_dom.tweetId });
|
|
}
|
|
}
|
|
@@ -770,17 +775,17 @@ function replaceDOMRedPacket(_type, _dom, postId, tweetId) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-let change_time = new Date().getTime()
|
|
|
|
-function onChangePageMain(port, targetNode) {
|
|
|
|
- const config = { attributes: true, childList: true, subtree: true };
|
|
|
|
- const callback = (mutationsList, observer) => {
|
|
|
|
- setTimeout(()=>{
|
|
|
|
- parseDOMRedPacketByShortUrl(port)
|
|
|
|
- },2000)
|
|
|
|
- }
|
|
|
|
- const observer = new MutationObserver(callback);
|
|
|
|
- observer.observe(targetNode, config);
|
|
|
|
-}
|
|
|
|
|
|
+// let change_time = new Date().getTime()
|
|
|
|
+// function onChangePageMain(port, targetNode) {
|
|
|
|
+// const config = { attributes: true, childList: true, subtree: true };
|
|
|
|
+// const callback = (mutationsList, observer) => {
|
|
|
|
+// setTimeout(() => {
|
|
|
|
+// parseDOMRedPacketByShortUrl(port)
|
|
|
|
+// }, 2000)
|
|
|
|
+// }
|
|
|
|
+// const observer = new MutationObserver(callback);
|
|
|
|
+// observer.observe(targetNode, config);
|
|
|
|
+// }
|
|
|
|
|
|
export function setIframeRedPacket(port) {
|
|
export function setIframeRedPacket(port) {
|
|
// let elment = document.documentElement
|
|
// let elment = document.documentElement
|
|
@@ -788,17 +793,17 @@ export function setIframeRedPacket(port) {
|
|
if (window.location.href.includes('twitter.com)')) {
|
|
if (window.location.href.includes('twitter.com)')) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // setInterval(() => {
|
|
|
|
- // // parseDOMRedPacketByShortUrl(port)
|
|
|
|
- // }, 1000)
|
|
|
|
|
|
+ setInterval(() => {
|
|
|
|
+ parseDOMRedPacketByShortUrl(port)
|
|
|
|
+ }, 1000)
|
|
|
|
|
|
|
|
|
|
- let targetNode = null
|
|
|
|
- let timer = setInterval(() => {
|
|
|
|
- targetNode = document.querySelector('main')
|
|
|
|
- if (targetNode) {
|
|
|
|
- clearInterval(timer)
|
|
|
|
- onChangePageMain(port, targetNode)
|
|
|
|
- }
|
|
|
|
- }, 1000);
|
|
|
|
|
|
+ // let targetNode = null
|
|
|
|
+ // let timer = setInterval(() => {
|
|
|
|
+ // targetNode = document.querySelector('main')
|
|
|
|
+ // if (targetNode) {
|
|
|
|
+ // clearInterval(timer)
|
|
|
|
+ // onChangePageMain(port, targetNode)
|
|
|
|
+ // }
|
|
|
|
+ // }, 1000);
|
|
}
|
|
}
|