Created
June 27, 2011 23:14
-
-
Save vayn/1050089 to your computer and use it in GitHub Desktop.
FireGestures script for google image search
This file contains hidden or 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
/** | |
* Author: | |
* Vayn a.k.a. VT <[email protected]> | |
* http://vayn.is-programmer.com | |
* | |
* URL: | |
* http://p.vim-cn.com/cbG/js | |
* | |
* File: googleImageSearch.js | |
* Create Date: 2011年 06月 27日 星期一 09:29:57 CST | |
*/ | |
var srcNode = FireGestures.sourceNode; | |
var imgURL = getComputedStyle(srcNode, '').getPropertyValue('background-image'); | |
if (imgURL == 'none') | |
imgURL = FireGestures.getImageURL(srcNode); | |
else | |
imgURL = imgURL.replace(/"|'/g,"").replace(/url\(|\)$/ig, ""); | |
if (!imgURL) | |
throw "Not on a image"; | |
// check the URL is safe | |
FireGestures.checkURL(imgURL, srcNode.ownerDocument); | |
imgURL = 'http://www.google.com/searchbyimage?image_url=' | |
+ encodeURIComponent(imgURL) + '&num=10' | |
// open image in new tab | |
var background = gPrefService.getBoolPref("browser.tabs.loadInBackground"); | |
if (event.shiftKey || event.ctrlKey) | |
background = !background; | |
gBrowser.loadOneTab(imgURL, null, null, null, background, false); |
The description seems a bit vague, and reading the code, I could quite figure out what the initial event/variable it's starting with. Do you think you could notate the exact purpose? Thanks!
This script is written for FireGestures https://addons.mozilla.org/en-us/firefox/addon/firegestures/
It enables you to search image in web page or background when you use a predefined gesture on it.
Please read this article and its doc for more information.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Gist Shell