Last active
August 15, 2023 17:40
-
-
Save Hoptimal/3339d1671d30940b9f793f996c2f658b to your computer and use it in GitHub Desktop.
Get latest docs link bookmarklet V2.js
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 originalURL, pageNameIndex, pageNameEndIndex, pageName, latestURL; | |
originalURL = location.href; | |
if (!originalURL.toString().includes('docs.servicenow.com')) { | |
alert('This does not appear to be a ServiceNow Docs page. This button only works for pages on docs.servicenow.com.'); | |
return; | |
} | |
if (originalURL.indexOf('/concept/') != -1) { | |
pageNameIndex = (originalURL.indexOf('/concept/') + 9); | |
} else { | |
pageNameIndex = originalURL.lastIndexOf('/') + 1; | |
} | |
pageNameEndIndex = (originalURL.indexOf('.html', pageNameIndex)); | |
pageName = originalURL.substring(pageNameIndex, pageNameEndIndex); | |
latestURL = 'https://docs.servicenow.com/csh?topicname=' + pageName + '&version=latest'; | |
navigator.clipboard.writeText(latestURL); | |
alert('Latest page URL copied to clipboard.\nNavigating to latest page version.'); | |
location.href = latestURL; | |
})(); | |
/* "Compiled" version: | |
javascript:(()=>{var originalURL,pageNameIndex,pageNameEndIndex,pageName,latestURL;originalURL=location.href;if(!originalURL.toString().includes("docs.servicenow.com")){alert("This does not appear to be a ServiceNow Docs page. This button only works for pages on docs.servicenow.com.");return}if(originalURL.indexOf("/concept/")!=-1){pageNameIndex=originalURL.indexOf("/concept/")+9}else{pageNameIndex=originalURL.lastIndexOf("/")+1}pageNameEndIndex=originalURL.indexOf(".html",pageNameIndex);pageName=originalURL.substring(pageNameIndex,pageNameEndIndex);latestURL="https://docs.servicenow.com/csh?topicname="+pageName+"&version=latest";navigator.clipboard.writeText(latestURL);alert("Latest page URL copied to clipboard.\nNavigating to latest page version.");location.href=latestURL})(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment