|
@@ -1,5 +1,5 @@
|
|
-/* eslint-disable */
|
|
|
|
import { getChromeStorage, setChromeStorage, LANDING_PAGE } from '../uilts/chromeExtension.js'
|
|
import { getChromeStorage, setChromeStorage, LANDING_PAGE } from '../uilts/chromeExtension.js'
|
|
|
|
+import { throttle } from '../uilts/help'
|
|
import { getTtwitterRequestToken, twitterLogin } from '../server/twitter.js'
|
|
import { getTtwitterRequestToken, twitterLogin } from '../server/twitter.js'
|
|
import { srcPublishSuccess } from '../http/publishApi'
|
|
import { srcPublishSuccess } from '../http/publishApi'
|
|
|
|
|
|
@@ -73,6 +73,8 @@ export function backTwitterPinLoginCode(code) {
|
|
export function renderDom(port) {
|
|
export function renderDom(port) {
|
|
if (window.location.href.indexOf('https://twitter.com') > -1) {
|
|
if (window.location.href.indexOf('https://twitter.com') > -1) {
|
|
_createBtnDom(port);
|
|
_createBtnDom(port);
|
|
|
|
+ onWindowResize();
|
|
|
|
+ checkHasDeBtn();
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
_addIframe();
|
|
_addIframe();
|
|
_addDeNetBtn();
|
|
_addDeNetBtn();
|
|
@@ -85,7 +87,14 @@ export function renderDom(port) {
|
|
* 展示give弹窗
|
|
* 展示give弹窗
|
|
*/
|
|
*/
|
|
export function showGiveDialogHandler(userInfo) {
|
|
export function showGiveDialogHandler(userInfo) {
|
|
- dom.iframe.contentWindow.postMessage({ actionType: 'CONTENT_SHOW_GIVE_DIALOG', userInfo }, '*');
|
|
|
|
|
|
+ let iframe = document.getElementById('iframe-content');
|
|
|
|
+ if(iframe) {
|
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_SHOW_GIVE_DIALOG', userInfo }, '*');
|
|
|
|
+ } else {
|
|
|
|
+ _addIframe();
|
|
|
|
+ let iframe = document.getElementById('iframe-content');
|
|
|
|
+ iframe.contentWindow.postMessage({ actionType: 'CONTENT_SHOW_GIVE_DIALOG', userInfo }, '*');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
export function showIframeHandler() {
|
|
export function showIframeHandler() {
|
|
@@ -114,7 +123,7 @@ export function showTwitterPublishDialogHandler(publishRes) {
|
|
postId: publishRes.postId,
|
|
postId: publishRes.postId,
|
|
srcContentId: twitterArtId
|
|
srcContentId: twitterArtId
|
|
}
|
|
}
|
|
- }).then((res) => {
|
|
|
|
|
|
+ }).then(() => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -169,12 +178,12 @@ function _addDeNetEditBtn(parent, dom, isClick = false) {
|
|
* 在dialog插入deNet按钮
|
|
* 在dialog插入deNet按钮
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
-function _addDeNetBtnToDialog() {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- let dialogScheduleBtn = _getScheduleDom(true);
|
|
|
|
- _addDeNetEditBtn(dialogScheduleBtn, dom.deBtn2);
|
|
|
|
- }, 800)
|
|
|
|
-}
|
|
|
|
|
|
+// function _addDeNetBtnToDialog() {
|
|
|
|
+// setTimeout(() => {
|
|
|
|
+// let dialogScheduleBtn = _getScheduleDom(true);
|
|
|
|
+// _addDeNetEditBtn(dialogScheduleBtn, dom.deBtn2);
|
|
|
|
+// }, 800)
|
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取左侧twitter按钮
|
|
* 获取左侧twitter按钮
|
|
@@ -231,7 +240,7 @@ function _addIframe() {
|
|
// const shadowRoot = span.attachShadow({mode: 'closed'})
|
|
// const shadowRoot = span.attachShadow({mode: 'closed'})
|
|
let iframe = document.createElement('iframe');
|
|
let iframe = document.createElement('iframe');
|
|
iframe.src = chrome.runtime.getURL('/iframe/publish.html')
|
|
iframe.src = chrome.runtime.getURL('/iframe/publish.html')
|
|
- iframe.id = 'iframe-test'
|
|
|
|
|
|
+ iframe.id = 'iframe-content'
|
|
iframe.style.cssText = 'position:fixed;top:0px;right:0;display:block; width:100%;height:100%;z-index:0; border: medium none;display:none';
|
|
iframe.style.cssText = 'position:fixed;top:0px;right:0;display:block; width:100%;height:100%;z-index:0; border: medium none;display:none';
|
|
// shadowRoot.appendChild(iframe);
|
|
// shadowRoot.appendChild(iframe);
|
|
// document.body.appendChild(span)
|
|
// document.body.appendChild(span)
|
|
@@ -316,11 +325,11 @@ function _createBtnDom(port) {
|
|
loadingImg.style.cssText = 'width:20px;height: 20px;margin-right:3px;-webkit-animation:load 1.1s infinite linear;';
|
|
loadingImg.style.cssText = 'width:20px;height: 20px;margin-right:3px;-webkit-animation:load 1.1s infinite linear;';
|
|
|
|
|
|
let style = document.createElement('style');
|
|
let style = document.createElement('style');
|
|
- style.innerHTML = " @-webkit-keyframes load{from{ transform: rotate(0deg);} to{transform: rotate(360deg);}}";
|
|
|
|
|
|
+ style.innerHTML = "#de-btn:hover{opacity: .9;};@-webkit-keyframes load{from{ transform: rotate(0deg);} to{transform: rotate(360deg);}}";
|
|
document.getElementsByTagName('head').item(0).appendChild(style);
|
|
document.getElementsByTagName('head').item(0).appendChild(style);
|
|
|
|
|
|
let deBtn = document.createElement('span');
|
|
let deBtn = document.createElement('span');
|
|
- const shadowDiv = document.createElement('div');
|
|
|
|
|
|
+ // const shadowDiv = document.createElement('div');
|
|
deBtn.innerHTML = '<span>DeNet</span>';
|
|
deBtn.innerHTML = '<span>DeNet</span>';
|
|
deBtn.id = 'de-btn';
|
|
deBtn.id = 'de-btn';
|
|
deBtn.style.cssText = 'width:90%;height: 52px;text-align:center;line-height:52px;margin-bottom: 4px;margin-top: 4px;background: linear-gradient(274.8deg, #FF9900 -3.69%, #BD00FF 69.71%, #00F0FF 122.65%);color:#fff;font-size:17px;font-weight:700;border-radius:100px;cursor: pointer;display: flex;align-items: center;justify-content: center;';
|
|
deBtn.style.cssText = 'width:90%;height: 52px;text-align:center;line-height:52px;margin-bottom: 4px;margin-top: 4px;background: linear-gradient(274.8deg, #FF9900 -3.69%, #BD00FF 69.71%, #00F0FF 122.65%);color:#fff;font-size:17px;font-weight:700;border-radius:100px;cursor: pointer;display: flex;align-items: center;justify-content: center;';
|
|
@@ -337,6 +346,11 @@ function _createBtnDom(port) {
|
|
deBtn2.style.cssText = smallDeBtnStyle;
|
|
deBtn2.style.cssText = smallDeBtnStyle;
|
|
deBtn2.src = "../assets/img/icon-gift-pack.png"
|
|
deBtn2.src = "../assets/img/icon-gift-pack.png"
|
|
|
|
|
|
|
|
+ const deBtn3 = document.createElement('img');
|
|
|
|
+ deBtn3.id = 'de-btn3'
|
|
|
|
+ deBtn3.src = require("../assets/img/icon-slider-de-net-btn.png");
|
|
|
|
+ deBtn3.style.cssText = 'width:52px;height: 52px;margin-top:20px;';
|
|
|
|
+
|
|
deBtn.addEventListener('click', () => {
|
|
deBtn.addEventListener('click', () => {
|
|
_deNetBtnClick(port);
|
|
_deNetBtnClick(port);
|
|
})
|
|
})
|
|
@@ -346,23 +360,61 @@ function _createBtnDom(port) {
|
|
deBtn2.addEventListener('click', () => {
|
|
deBtn2.addEventListener('click', () => {
|
|
_deNetBtnClick(port);
|
|
_deNetBtnClick(port);
|
|
})
|
|
})
|
|
|
|
+ deBtn3.addEventListener('click', () => {
|
|
|
|
+ _deNetBtnClick(port);
|
|
|
|
+ })
|
|
dom.deBtn = deBtn;
|
|
dom.deBtn = deBtn;
|
|
dom.deBtn1 = deBtn1;
|
|
dom.deBtn1 = deBtn1;
|
|
dom.deBtn2 = deBtn2;
|
|
dom.deBtn2 = deBtn2;
|
|
|
|
+ dom.deBtn3 = deBtn3;
|
|
dom.loadingImg = loadingImg;
|
|
dom.loadingImg = loadingImg;
|
|
}
|
|
}
|
|
|
|
|
|
-setInterval(() => {
|
|
|
|
- let toolBar = document.querySelector('div[data-testid="toolBar"]');
|
|
|
|
- let innerDeIcon = document.getElementById('de-icon');
|
|
|
|
- if (toolBar && !innerDeIcon) {
|
|
|
|
- let dialogScheduleBtn = _getScheduleDom(false);
|
|
|
|
- _addDeNetEditBtn(dialogScheduleBtn, dom.deBtn1);
|
|
|
|
- }
|
|
|
|
-}, 800)
|
|
|
|
|
|
+function onWindowResize () {
|
|
|
|
+ window.onresize = throttle(function() {
|
|
|
|
+ try {
|
|
|
|
+ if(window.innerWidth < 1270) {
|
|
|
|
+ let bigBtn = document.querySelector('#de-btn');
|
|
|
|
+ bigBtn && bigBtn.remove();
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ let smallDom = document.querySelector('header[role="banner"]').querySelector('.r-1awozwy');
|
|
|
|
+ if (smallDom) {
|
|
|
|
+ smallDom.appendChild(dom.deBtn3);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ let smallBtn = document.querySelector('#de-btn3');
|
|
|
|
+ smallBtn && smallBtn.remove();
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ let bigDom = document.querySelector('header[role="banner"]').querySelector('.r-1habvwh');
|
|
|
|
+ if (bigDom) {
|
|
|
|
+ bigDom.appendChild(dom.deBtn);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ }
|
|
|
|
+ }, 2000)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function checkHasDeBtn () {
|
|
|
|
+ setInterval(() => {
|
|
|
|
+ try {
|
|
|
|
+ let toolBar = document.querySelector('div[data-testid="toolBar"]');
|
|
|
|
+ let innerDeIcon = document.getElementById('de-icon');
|
|
|
|
+ if (toolBar && !innerDeIcon) {
|
|
|
|
+ let dialogScheduleBtn = _getScheduleDom(false);
|
|
|
|
+ _addDeNetEditBtn(dialogScheduleBtn, dom.deBtn1);
|
|
|
|
+ }
|
|
|
|
+ } catch(e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ }
|
|
|
|
+ }, 1000)
|
|
|
|
+}
|
|
|
|
|
|
function parseDOMRedPacket() {
|
|
function parseDOMRedPacket() {
|
|
- let _dom = null
|
|
|
|
|
|
+ // let _dom = null
|
|
// let denet_arr = document.querySelector('article[data-testid=tweet]').querySelectorAll('a')
|
|
// let denet_arr = document.querySelector('article[data-testid=tweet]').querySelectorAll('a')
|
|
// let _dom = null
|
|
// let _dom = null
|
|
// for (let i in denet_arr) {
|
|
// for (let i in denet_arr) {
|