New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special pages #97

Merged
merged 1 commit into from Sep 8, 2017
Jump to file or symbol
Failed to load files and symbols.
+36 −1
Diff settings

Always

Just for now

Copy path View file
@@ -95,6 +95,14 @@ function copyStaticFiles(browser) {
}
function copySpecialPagesFile(browser) {
logStep(`Copying special pages file for ${browser}...`)
fse.copySync(
path.join(srcAssembleDir, `specialPages.${browser}.js`),
path.join(pathToBuild(browser), 'specialPages.js'))
}
function mergeManifest(browser) {
logStep('Merging manifest.json...')
const common = path.join('..', srcAssembleDir, 'manifest.common.json')
@@ -185,6 +193,7 @@ browsers.forEach((browser) => {
logStep(chalk.bold(`Building for ${browser}...`))
copyStaticFiles(browser)
copySpecialPagesFile(browser)
mergeManifest(browser)
copyCompatibilityShimAndContentScriptInjector(browser)
getPngs(sp, browser)
@@ -15,6 +15,7 @@
"background": {
"scripts": [
"sendToActiveTab.js",
"specialPages.js",
"background.js"
]
},
@@ -0,0 +1,6 @@
'use strict'
/* exported specialPages */
const specialPages = Object.freeze([
/^https:\/\/chrome.google.com\/webstore/
])
@@ -0,0 +1,6 @@
'use strict'
/* exported specialPages */
const specialPages = Object.freeze([
/^https:\/\/addons.mozilla.org/
])
@@ -0,0 +1,6 @@
'use strict'
/* exported specialPages */
const specialPages = Object.freeze([
/^https:\/\/addons.opera.com/
])
Copy path View file
@@ -1,5 +1,5 @@
'use strict'
/* global sendToActiveTab landmarksContentScriptInjector */
/* global sendToActiveTab landmarksContentScriptInjector specialPages */
//
// Keyboard Shortcut Handling
@@ -43,6 +43,13 @@ browser.webNavigation.onCompleted.addListener(function(details) {
function checkBrowserActionState(tabId, url) {
if (/^(https?|file):\/\//.test(url)) { // TODO DRY
for (const specialPage of specialPages) {
if (specialPage.test(url)) {
console.log(`Landmarks: disabling extension on ${url}`)
browser.browserAction.disable(tabId)
return
}
}
browser.browserAction.enable(tabId)
} else {
browser.browserAction.disable(tabId)
ProTip! Use n and p to navigate between commits in a pull request.