-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.js
23 lines (21 loc) · 858 Bytes
/
hook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Search-By-Image URL-sbi search hook - content script
// 2013-05-06 ~keroserene
// Prepare the search-by-image box for listener.
console.log('Opening SBI box.');
var sbiLink = document.getElementsByClassName('gsst_a')[0];
if (undefined == sbiLink) {
console.log('sbixurl warning: No Search-By-Image button found!')
}
sbiLink.click();
// Wait for the requested image url before firing an sbi request.
// |info| is a contextMenu OnClickData.
chrome.extension.onMessage.addListener(
function(info, from, callback) {
var url = info.srcUrl;
console.log('Automatic Search-By-Image: ' + url);
// Assume we're focused correctly after the initial sbi-box is opened.
sbi_input = document.activeElement
sbi_input.value = url;
sbi_input.form.submit();
callback(); // Fires the next content script which does actual url yanking.
});