12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- var port = chrome.runtime.connect({
- name: "hello",
- });
- import {
- contentTwitterPinLogin,
- renderDom,
- showGiveDialogHandler,
- showIframeHandler,
- hideIframeHandler,
- showTwitterPublishDialogHandler,
- setIframeRedPacket,
- } from "../logic/twitter.js";
- import { getChromeStorage } from "../uilts/chromeExtension";
- port.onMessage.addListener(function (res) {
- switch (res.state) {
- case "BACK_TWITTER_LOGIN_SUCCESS":
- showGiveDialogHandler();
- break;
- }
- });
- chrome.storage.onChanged.addListener(changes => {
- if (changes.executeScript) {
- let item = JSON.parse(changes.executeScript.newValue)
- if (item.executeScript) {
- location.reload()
- init()
- console.log('yeeee')
- }
- }
- })
- window.onload = () => {
- init()
- };
- function init() {
- contentTwitterPinLogin(port);
- renderDom(port);
- setIframeRedPacket();
- getChromeStorage("popupShowPublishDialog", (res) => {
- console.log("popupShowPublishDialog", res);
- if (res && res.show) {
- setTimeout(() => {
- showTwitterPublishDialogHandler({
- srcContent: res.srcContent,
- postId: res.postId
- });
- }, 1500);
- chrome.storage.local.remove("popupShowPublishDialog");
- }
- });
- }
- window.onmessage = (res) => {
- if (res.data && res.data.actionType) {
- switch (res.data.actionType) {
- case "IFRAME_SHOW_IFREME":
- showIframeHandler();
- break;
- case "IFRAME_HIDE_IFREME":
- hideIframeHandler();
- break;
- case "IFRAME_SHOW_TWITTER_PUBLISH_DIALOG":
- showTwitterPublishDialogHandler(res.data.publishRes);
- break;
- }
- }
- };
|