Created
July 26, 2016 19:20
-
-
Save dmelcer9/066d2b050bbdfeafbe0842146b970c19 to your computer and use it in GitHub Desktop.
Super simple chrome extension to banish old javadoc from the web.
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
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) { | |
console.log("Tab changed"); | |
if(changeInfo.status == 'complete'){ | |
console.log("Tab changed 2"); | |
chrome.tabs.getSelected(null,function(tab){ | |
if(tab){ | |
console.log("Tab defined"); | |
var current = tab.url; | |
console.log(current); | |
var regex = /(https?:\/\/docs\.oracle\.com\/javase\/)(.*)(\/docs\/api.*)/i; | |
if(regex.test(current)){ | |
console.log("Matched URL"); | |
var url = regex.exec(current); | |
var newurl = url[1]+"8"+url[3]; | |
if(url[2]!="8"&&url[3]) | |
chrome.tabs.update(tab.id, {url: newurl}); | |
} | |
} | |
}); | |
} | |
}); |
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
{ | |
"manifest_version": 2, | |
"name": "Javadoc Redirect", | |
"description": "Redirect old javadoc to new javadoc", | |
"version": "1.0", | |
"background": { | |
"scripts": ["JavadocRedirect.js"] | |
}, | |
"permissions": [ | |
"tabs" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment