Skip to content

Instantly share code, notes, and snippets.

@mtandre
Last active August 2, 2016 19:28
Show Gist options
  • Save mtandre/5d2f537c57cdc3fd88ba to your computer and use it in GitHub Desktop.
Save mtandre/5d2f537c57cdc3fd88ba to your computer and use it in GitHub Desktop.
CMS Bookmarklet: Open current page in CMS search
javascript:(function() {
var siteCodes = {"www.jsonline.com": "PMJS"};
var siteCode = siteCodes[window.location.host];
if (siteCode === "PMJS") {
var id = parseInt(window.location.pathname.split("/").slice(-2)[0],10);
if (id > 0) {
var searchUrl = 'https://presto-wigroup.gannettdigital.com/#/?k=' + id + '&st=' + siteCode + '&pg=1&pgs=25';
window.open(searchUrl, '_blank');
}
} else {
alert("This only works on www.jsonline.com.");
}
})();
// minified
//javascript:(function(){var siteCodes={"www.jsonline.com":"PMJS"},siteCode=siteCodes[window.location.host];if("PMJS"===siteCode){var id=parseInt(window.location.pathname.split("/").slice(-2)[0],10);if(0<id){var searchUrl="https://presto-wigroup.gannettdigital.com/#/?k="+id+"&st="+siteCode+"&pg=1&pgs=25";window.open(searchUrl,"_blank")}}else alert("This only works on www.jsonline.com.");})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment