


I am using looking to have a Javascript for browser bookmark so, the live page URL converts to the Author editor URL with just a click. That way it saves time digging in the Sites to find the page.
Can anyone help me with this?
Thank you!
Views
Replies
Sign in to like this content
Total Likes
@djoshinp What you need in this case is a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) which is a bookmark that runs JavaScript. See the below for an example:
javascript\: (() => { let pagePath = window.location.pathname.substring(1); pagePath = pagePath.replace(/\/$/, ''); const anchorElement = document.createElement('a'); anchorElement.href = `http://localhost:4502/editor.html/${pagePath}.html`; anchorElement.target = '_blank'; anchorElement.click(); })();
Be aware that javascript\: is required to inform the browser that it needs to execute JavaScript in the context of this bookmark. Also note that the backslash in javascript\: is only for escaping purposes here. See the link for examples of the correct formatting.
Here is what this does:
There are some assumptions here:
If you need more configuration an extension would be better but that is beyond this forum.
Hope that helps.
@djoshinp What you need in this case is a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) which is a bookmark that runs JavaScript. See the below for an example:
javascript\: (() => { let pagePath = window.location.pathname.substring(1); pagePath = pagePath.replace(/\/$/, ''); const anchorElement = document.createElement('a'); anchorElement.href = `http://localhost:4502/editor.html/${pagePath}.html`; anchorElement.target = '_blank'; anchorElement.click(); })();
Be aware that javascript\: is required to inform the browser that it needs to execute JavaScript in the context of this bookmark. Also note that the backslash in javascript\: is only for escaping purposes here. See the link for examples of the correct formatting.
Here is what this does:
There are some assumptions here:
If you need more configuration an extension would be better but that is beyond this forum.
Hope that helps.
Hi @djoshinp
Not sure if you have already explored chrome plugins, there are a lot, you can explore, but one I do remember is this one https://chrome.google.com/webstore/detail/esri-aem-chrome-extension/olnobjdmmkloilfjcflfpkponphjpchi... ,
it does exactly the same thing that you have mentioned in your use case.
Otherwise, you can refer to the solution provided by @cshawaus.
Hope this helps!
Regards,
Nitesh
The following instructions are based on Chrome's bookmarking system. The script provided references a meta tag that contains the content path of the page (e.g.<meta name="aem-content-path" content="/content/mysite/en/mypage">).
javascript:(function()%7Bvar%20aem_content_path%20%3D%20document.querySelector('meta%5Bname%3D%22aem-content-path%22%5D').content%3Bdocument.location.href%3D'https%3A%2F%2Fstgauthor.yourdomain.com%2Feditor.html'%20%2B%20aem_content_path%20%2B%20'.html'%7D)()