Created
August 7, 2013 23:13
-
-
Save tikurahul/6179854 to your computer and use it in GitHub Desktop.
A technique to supercharge Chome's "Manage Search Engines" feature. Map this JavaScript URL to a Search Engine (e.g super), and then you can do something like: super [TAB] "code packageName branchName" which will get mapped to "https://code.amazon.com/packages/packageName/trees/branchName/"
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
javascript: | |
var patterns = { | |
'vs': 'https://devcentral.amazon.com/ac/brazil/directory/version-set/packages/{0}/{1}', | |
'code': 'https://code.amazon.com/packages/{0}/trees/{1}/' | |
}; | |
var pattern = decodeURIComponent('%s'); | |
var keys = pattern.split(' '); | |
var base = keys ? keys[0] : ''; | |
var args = keys ? keys.slice(1) : []; | |
var url = patterns[base] || ''; | |
if (url) { | |
url = url.replace(/\{(\d+)\}/g, function(match, param) { | |
return (typeof args[param] != 'undefined' ? args[param] : match); | |
}); | |
location.assign(url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment