-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nicer icon, change icon on success only, formatting
- Loading branch information
Showing
6 changed files
with
55 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This is a chrome extension to save image from https://zespolmi.pl to clipboard | ||
This is a chrome extension to copy image from https://zespolmi.pl to clipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
chrome.browserAction.onClicked.addListener(function() { | ||
chrome.tabs.query({ | ||
currentWindow: true, | ||
active: true | ||
}, function(tab) { | ||
chrome.tabs.sendMessage(tab[0].id, {message: "copy_image"}); | ||
|
||
chrome.browserAction.setIcon({ | ||
path: "icon-saved.png", | ||
tabId: tab[0].id | ||
}); | ||
|
||
setTimeout(function(){ | ||
chrome.browserAction.onClicked.addListener(function () { | ||
chrome.tabs.query({ | ||
currentWindow: true, | ||
active: true | ||
}, function (tab) { | ||
chrome.tabs.sendMessage(tab[0].id, { message: "copy_image" }); | ||
}); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener( | ||
function(request) { | ||
if (request.message == "success") | ||
chrome.browserAction.setIcon({ | ||
path: "icon.png", | ||
tabId: tab[0].id | ||
path: "icon-saved.png" | ||
}); | ||
}, 2000) | ||
|
||
}); | ||
}); | ||
|
||
setTimeout(function () { | ||
chrome.browserAction.setIcon({ | ||
path: "icon.png" | ||
}); | ||
}, 2000) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
function (request, sender, sendResponse) { | ||
|
||
if( request.message === "copy_image" ) { | ||
const img = document.querySelector("#contentimg .img-responsive"); | ||
if(img){ | ||
var canvas = document.createElement("canvas"); | ||
canvas.width = img.naturalWidth; | ||
canvas.height = img.naturalHeight; | ||
canvas.getContext("2d").drawImage(img, 0, 0); | ||
canvas.toBlob(function(blob) { | ||
navigator.clipboard.write([ | ||
if (request.message === "copy_image") { | ||
const img = document.querySelector("#contentimg .img-responsive"); | ||
|
||
if (img) { | ||
var canvas = document.createElement("canvas"); | ||
canvas.width = img.naturalWidth; | ||
canvas.height = img.naturalHeight; | ||
canvas.getContext("2d").drawImage(img, 0, 0); | ||
|
||
canvas.toBlob(function (blob) { | ||
navigator.clipboard.write([ | ||
new ClipboardItem({ | ||
[blob.type]: blob | ||
}) | ||
]) | ||
}); | ||
]); | ||
}); | ||
|
||
chrome.runtime.sendMessage({message: "success"}); | ||
} | ||
} | ||
} | ||
} | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "ZespolMi - image saver", | ||
"description": "Save the current image from zespolmi.pl", | ||
"version": "1.0", | ||
"name": "ZespolMi - image copier", | ||
"description": "Copy the current image from zespolmi.pl to clipboard", | ||
"version": "1.1", | ||
"background": { | ||
"scripts": ["background.js"] | ||
"scripts": [ | ||
"background.js" | ||
] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["https://zespolmi.pl/*"], | ||
"js": ["content.js"] | ||
"matches": [ | ||
"https://zespolmi.pl/*" | ||
], | ||
"js": [ | ||
"content.js" | ||
] | ||
} | ||
], | ||
"permissions": ["tabs"], | ||
], | ||
"permissions": [ | ||
"tabs" | ||
], | ||
"browser_action": { | ||
"default_icon": "icon.png", | ||
"default_title": "Save" | ||
"default_title": "Copy" | ||
} | ||
} |