Skip to content

Commit

Permalink
#3 added conditional check for whether copyting is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Salmon committed Feb 23, 2018
1 parent 6d679d1 commit 286d476
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 9 additions & 2 deletions app/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ chrome.runtime.onMessage.addListener(
browser.notifications.create({
"type": "basic",
"title": "Copy Failed",
"message": "Copying " + x.type + " files are unsupported. \nDownload or use the right click context menu."
"message": "Copying " + x.type.split('/')[1] + " images are not supported. \nDownload or use the right click context menu."
});
return;
}
Expand All @@ -52,4 +52,11 @@ chrome.runtime.onMessage.addListener(
});
});
};
});
});

// Save browser version in settings
browser.runtime.getBrowserInfo().then(function(info, e) {
chrome.storage.local.set({
copySupported: info.version.split('.')[0] >= 57
});
});
10 changes: 6 additions & 4 deletions app/js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var defaultSettings = {
newTab: true,
openVisible: true,
primary: "view",
placement: "default"
placement: "default",
copySupported: false
}

// Renderers
Expand All @@ -17,6 +18,7 @@ function renderUI() {
chrome.storage.local.get(null, function(settings) {
settings = Object.assign(defaultSettings, settings);


var template = document.createElement('template');
var settingsTemplate = document.createElement('template');

Expand All @@ -25,7 +27,7 @@ function renderUI() {
var view = `<a class="virLink" ` + (settings.newTab ? 'target="_blank"' : '') + `>
<span>View Image</span>
</a>`;
var copy = `<a class="virCopyImage" ><span>Copy Image</span></a>`;
var copy = settings.copySupported ? `<a class="virCopyImage" ><span>Copy Image</span></a>` : '';
var save = `<a class="virSaveImage" ><span>Download</span></a>`;
var primary = '';
var sec1 = '';
Expand Down Expand Up @@ -205,8 +207,8 @@ function SettingsOpen() {
<input type="radio" id="virPrimaryView" name="primary" value="view" ` + (settings.primary == "view" ? "checked" : "") + `>
<label for="virPrimaryView">View Image</label><br>
<input type="radio" id="virPrimaryCopy" name="primary" value="copy" ` + (settings.primary == "copy" ? "checked" : "") + `>
<label for="virPrimaryCopy">Copy Image</label><br>
` + (settings.copySupported ? `<input type="radio" id="virPrimaryCopy" name="primary" value="copy" ` + (settings.primary == "copy" ? "checked" : "") + `>
<label for="virPrimaryCopy">Copy Image</label><br>` : '') + `
<input type="radio" id="virPrimarySave" name="primary" value="save" ` + (settings.primary == "save" ? "checked" : "") + `>
<label for="virPrimarySave">Download Image</label>
Expand Down
4 changes: 2 additions & 2 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Brings back the 'View Image' and 'Search by Image' options in google image search results, as well as adding copy and download options.",
"manifest_version": 2,
"name": "View Image Resurrected",
"version": "1.8.1",
"version": "1.8.2",
"permissions": [
"webRequest",
"<all_urls>",
Expand All @@ -18,7 +18,7 @@
},
"applications": {
"gecko": {
"strict_min_version": "57.0a1"
"strict_min_version": "51.0a1"
}
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "view-image-resurrected",
"version": "1.8.1",
"version": "1.8.2",
"description": "![Icon](icons/icon-96.png)\r # View Image Resurrected",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 286d476

Please sign in to comment.