content.js 801 B

123456789101112131415161718192021222324252627282930313233343536
  1. var port = chrome.runtime.connect({ name: "hello" });
  2. import {
  3. contentTwitterPinLogin, renderDom, showGiveDialogHandler, showIframeHandler, hideIframeHandler,
  4. showTwitterPublishDialogHandler, setIframeRedPacket
  5. } from '../logic/twitter.js'
  6. port.onMessage.addListener(function (res) {
  7. switch (res.state) {
  8. case 'BACK_TWITTER_LOGIN_SUCCESS':
  9. showGiveDialogHandler();
  10. break;
  11. }
  12. })
  13. window.onload = () => {
  14. contentTwitterPinLogin(port)
  15. renderDom(port);
  16. setIframeRedPacket()
  17. }
  18. window.onmessage = (res) => {
  19. if (res.data && res.data.actionType) {
  20. switch (res.data.actionType) {
  21. case "showIframe":
  22. showIframeHandler();
  23. break;
  24. case "hideIframe":
  25. hideIframeHandler();
  26. break;
  27. case "showTwitterPublishDialog":
  28. showTwitterPublishDialogHandler()
  29. break;
  30. }
  31. }
  32. }