forked from maxf/textorizer-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
23 lines (21 loc) · 817 Bytes
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
oncontextmenu = function(e) {
if (!e.ctrlKey && !e.shiftKey && e.altKey) e.preventDefault(); else return;
var img = e.target.localName == 'img' ? e.target.src
: getComputedStyle(e.target, null).getPropertyValue('background-image');
if ((img = img.replace(/^url\((.*)\)$/, "$1")) == 'none') return;
// send the URL found to the main page
chrome.extension.sendRequest({image: img});
/*
var dir = img.split('/');
var tmp = document.body.appendChild(document.createElement('form'));
tmp.action = 'http://www.pixlr.com/editor/';
tmp.target = '_blank';
[['image', img], ['title', dir[dir.length - 1]]].forEach(function(i) {
var val = tmp.appendChild(document.createElement('input'));
val.name = i[0];
val.value = i[1];
});
tmp.submit();
document.body.removeChild(tmp);
*/
};