diff --git a/src/background.js b/src/background.js index 4cd01dc29..ba460ef01 100644 --- a/src/background.js +++ b/src/background.js @@ -1,23 +1,23 @@ -import './lib/initPolyfills'; import uid from 'uuid'; -import { phishingCheckUrl, getPhishingUrls, setPhishingUrl } from './popup/utils/phishing-detect'; -import { detectConnectionType } from './popup/utils/helper'; -import { buildTx } from './popup/utils'; -import WalletController from './wallet-controller'; -import Notification from './notifications'; +import { setController, switchNode } from './lib/background-utils'; +import './lib/initPolyfills'; +import { PopupConnections } from './lib/popup-connection'; +import RedirectChainNames from './lib/redirect-chain-names'; import rpcWallet from './lib/rpcWallet'; +import TipClaimRelay from './lib/tip-claim-relay'; +import Notification from './notifications'; +import { buildTx } from './popup/utils'; +import { popupProps } from './popup/utils/config'; import { - HDWALLET_METHODS, AEX2_METHODS, - NOTIFICATION_METHODS, CONNECTION_TYPES, DEFAULT_NETWORK, + HDWALLET_METHODS, + NOTIFICATION_METHODS, } from './popup/utils/constants'; -import { popupProps } from './popup/utils/config'; -import TipClaimRelay from './lib/tip-claim-relay'; -import RedirectChainNames from './lib/redirect-chain-names'; -import { setController, switchNode } from './lib/background-utils'; -import { PopupConnections } from './lib/popup-connection'; +import { detectConnectionType } from './popup/utils/helper'; +import { getPhishingUrls, phishingCheckUrl, setPhishingUrl } from './popup/utils/phishing-detect'; +import WalletController from './wallet-controller'; import Logger from './lib/logger'; const controller = new WalletController(); @@ -113,6 +113,26 @@ if (process.env.IS_EXTENSION && require.main.i === module.id) { } } }); + + const contextMenuItem = { + id: 'superheroTip', + title: 'Tip', + }; + + browser.contextMenus.removeAll(); + browser.contextMenus.create(contextMenuItem); + browser.contextMenus.onClicked.addListener(({ menuItemId, pageUrl }) => { + if (menuItemId === 'superheroTip') { + const url = `/tip?url=${pageUrl}`; + localStorage.setItem('tipUrl', url); + browser.windows.create({ + url: `popup/popup.html#${url}`, + type: 'popup', + height: 600, + width: 375, + }); + } + }); } // eslint-disable-next-line import/prefer-default-export diff --git a/src/manifest.js b/src/manifest.js index c395c489c..ab5702a9e 100644 --- a/src/manifest.js +++ b/src/manifest.js @@ -16,6 +16,7 @@ module.exports = (isProd, platform) => ({ 'videoCapture', 'activeTab', 'clipboardWrite', + 'contextMenus', 'notifications', 'tabs', 'webRequest', diff --git a/src/popup/router/index.js b/src/popup/router/index.js index a82b6915c..19d2f860e 100644 --- a/src/popup/router/index.js +++ b/src/popup/router/index.js @@ -52,6 +52,11 @@ router.beforeEach(async (to, from, next) => { await helper.pollGetter(() => store.state.isRestored); if (store.getters.isLoggedIn) { if (!store.getters.sdk) wallet.initSdk(); + if (localStorage.tipUrl) { + next(localStorage.tipUrl); + delete localStorage.tipUrl; + return; + } next(to.meta.ifNotAuthOnly ? '/account' : undefined); return; } @@ -62,6 +67,9 @@ router.beforeEach(async (to, from, next) => { return; } wallet.initSdk(); + + if (localStorage.tipUrl) delete localStorage.tipUrl; + if (window.RUNNING_IN_POPUP) { store.commit('SET_AEPP_POPUP', true); next( diff --git a/src/popup/router/pages/ClaimTips.vue b/src/popup/router/pages/ClaimTips.vue index 846326f47..d45cd3d5d 100644 --- a/src/popup/router/pages/ClaimTips.vue +++ b/src/popup/router/pages/ClaimTips.vue @@ -1,5 +1,8 @@