I need to develop an extension where every time I write url and in chrome and press enter. My url is crawled first if it matches some pattern, e.g. if youtube is in the url url, redirect it to facebook
This should be done automatically - not every time I click the (chrome extension) icon, that is, this script or piece of code will not start when I click, and after installing it, it will always check the URL entered and make the necessary changes and reload the tab.
Please help me. I reach this far
<html>
<script>
function getname()
{
chrome.tabs.getSelected( null , function(tab) {
var rawurl="http://www.youtube.com/watch?";
var newurl= "http://www.youtube.com/watch?feature=player_leanback&"
if (0 === tab.url.indexOf(rawurl))
chrome.tabs.update(tab.id, {url: tab.url.replace(rawurl,newurl)});
});
}
</script>
<body onload="getname();">
</body>
</html>
I achieve this, but you are loading the event into J-Script - anyway, I can do this all the time without using onload (), since onload requires an explicit click all the time.