denet.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { getChromeStorage } from '@/uilts/chromeExtension.js'
  2. import { payAchNoticeUrl } from '@/http/configAPI'
  3. export const closeAchPayNoticeHandler = async () => {
  4. let res = await getCurrentTab();
  5. if(res.url.startsWith(payAchNoticeUrl)) {
  6. chrome.tabs.remove(
  7. res.id, () => {
  8. getChromeStorage('achPayInfo', (result) => {
  9. let {tab, form} = result || {};
  10. chrome.storage.local.remove("achPayInfo");
  11. if(form == 'popupPage') {
  12. setChromeStorage({ achPayData : JSON.stringify({
  13. form: 'popupPage'
  14. })});
  15. }
  16. if(tab) {
  17. chrome.tabs.highlight({ windowId: res.tab.windowId, tabs: res.tab.index })
  18. }
  19. })
  20. }
  21. )
  22. }
  23. }
  24. const getCurrentTab = async () => {
  25. let queryOptions = { active: true, lastFocusedWindow: true };
  26. let [tab] = await chrome.tabs.query(queryOptions);
  27. return tab || {};
  28. }