Skip to content

Commit

Permalink
Fix Can't pick colors from web. Fixes #166
Browse files Browse the repository at this point in the history
Not sure how I missed this when testing, but should be ok now.
  • Loading branch information
kepi committed Mar 22, 2021
1 parent dea2a6e commit be68dcd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function bgPageReady() {
*
*/

function pickButton(enabled, message = '') {
function pickButton(tab, enabled, message = '') {
let pick_el = document.getElementById('pick')
if (enabled) {
pick_el.onclick = () => {
Expand Down Expand Up @@ -211,29 +211,31 @@ function initPickButton(tab) {
// special chrome pages
if (tab.url === undefined || tab.url.indexOf('chrome') == 0) {
pickButton(
tab,
false,
"Chrome doesn't allow <i>extensions</i> to play with special Chrome pages like this one. <pre>chrome://...</pre>",
)
}
// chrome gallery
else if (tab.url.indexOf('https://chrome.google.com/webstore') == 0) {
pickButton(false, "Chrome doesn't allow its <i>extensions</i> to play on Web Store.")
pickButton(tab, false, "Chrome doesn't allow its <i>extensions</i> to play on Web Store.")
}
// local pages
else if (tab.url.indexOf('file') === 0) {
chrome.extension.isAllowedFileSchemeAccess((isAllowedAccess) => {
if (isAllowedAccess) {
pickButton(true)
pickButton(tab, true)
} else {
pickButton(
tab,
false,
'<strong>Eye Dropper</strong> can\'t access local pages unless you grant it the permission. Check <a href="#" id="link-help-file-urls" data-url="https://eyedropper.test/help/file-urls">the instructions how to allow it</a>.',
)
initExternalLink(document.getElementById('link-help-file-urls'))
}
})
} else {
pickButton(true)
pickButton(tab, true)
}
}

Expand Down

0 comments on commit be68dcd

Please sign in to comment.