AEM - Browser Extension to Open Publish Page in Author


Develop simple Chrome and Firefox browser Access and Edit Extension to open a published page in author instance. Assuming author is on default port http://localhost:4502 and publish on http://localhost:4503, this extension allows user to open a published page, for authoring in a new browser tab. Eg. if user has published page http://localhost:4503/content/geometrixx-outdoors/en.html open in a browser tab, clicking on the extension opens Classic UI http://localhost:4502/cf#/content/geometrixx-outdoors/en.html in new tab (if not logged in on author instance, the login page is shown first)


A very useful chrome extension that every AEM developer should have is available on chrome web store



Develop for Chrome

1) Create a folder C:\dev\open-page-in-author-browser-ext\chrome

2) Create file C:\dev\open-page-in-author-browser-ext\chrome\manifest.json with following data. Script eaem.js is the runtime for extension with necessary JS logic to open a new tab

    "manifest_version": 2,
    "name": "Access and Edit",
    "description": "Access and Editing Tool for Adobe Experience Manager",
    "version": "1.0",

    "browser_action": {
        "default_icon": "pencil.png"

    "permissions": [

    "background": {
        "scripts": ["eaem.js"]

3) Add the pencil icon to C:\dev\open-page-in-author-browser-ext\chrome

4) Create file C:\dev\open-page-in-author-browser-ext\chrome\eaem.js and add following code

    var authorPrefix = 'http://localhost:4502';

    chrome.browserAction.onClicked.addListener(function(tab) {
        chrome.tabs.getSelected(null, function(tab){
            var parser = document.createElement('a');
            parser.href = tab.url;

            var path = "";

            if(parser.pathname.indexOf("/cf") == 0){
                path = parser.pathname + parser.hash +;
                path = "/cf#" + parser.pathname +;

            path = authorPrefix + path;

            chrome.tabs.create({url : path});

5) Chrome enables only web store extensions (and this extension is not web store worthy :) ); to use this extension use chrome developer mode and load it

6) A small pencil icon should appear on the top right of chrome; open any page on publish in a tab eg. http://localhost:4503/content/geometrixx-outdoors/en/women.html, click on the pencil and chrome opens the same page on author in new tab (a login page if user was not already authenticated)

8) Download code as zip

Develop for Firefox

1) Create a folder C:\dev\open-page-in-author-browser-ext\firefox

2) Create file C:\dev\open-page-in-author-browser-ext\firefox\install.rdf with following xml. Just bragging about yourself :)

<?xml version="1.0"?>
<RDF xmlns="" xmlns:em="">
    <Description about="urn:mozilla:install-manifest">
        <em:name>Access and Edit</em:name>
        <em:description>Access and Editing Tool for Adobe Experience Manager</em:description>
        <em:creator>Experience AEM</em:creator>

3) Create file C:\dev\open-page-in-author-browser-ext\firefox\chrome.manifest with following content, overlaying the browser chrome for adding your extension pencil button; the extension will be available in eaem folder

content eaem content/

overlay chrome://browser/content/browser.xul  chrome://eaem/content/eaem.xul

4) Create file C:\dev\open-page-in-author-browser-ext\firefox\content\pencil.png

5) Create file C:\dev\open-page-in-author-browser-ext\firefox\content\ with author hostname property (read in extension JS logic)

                     author.prefix = http://localhost:4502

6) Create file C:\dev\open-page-in-author-browser-ext\firefox\content\eaem.xul, overlay file assembling the extension (adding pencil, click action etc.)

<?xml version="1.0"?>
<overlay id="eaem-browser-overlay"

    <script type="application/x-javascript" src="chrome://eaem/content/eaem.js" />

    <stringbundleset id="stringbundleset">
        <stringbundle id="eaem-string-bundle"
                      src="chrome://eaem/content/" />

    <toolbarpalette id="BrowserToolbarPalette">
        <toolbarbutton id="eaem-navbar-button"
                       class="toolbarbutton-1 chromeclass-toolbar-additional"
                       label="Access Edit"
                       tooltiptext="Access and Editing"


7) Create file C:\dev\open-page-in-author-browser-ext\firefox\content\eaem.js with necessary logic to open page in new tab

if ("undefined" == typeof(ExperienceAEM)) {
    var ExperienceAEM = {};

ExperienceAEM.AccessAndEditing = {
    init : function () {
        var navbar = document.getElementById("nav-bar");
        var newset = navbar.currentSet + ',eaem-navbar-button';
        navbar.currentSet = newset;
        navbar.setAttribute("currentset", newset );
        document.persist("nav-bar", "currentset");

    open: function(aEvent) {
        var bundle = document.getElementById("eaem-string-bundle");

            window.alert("Missing ''");

        var hostPrefix = bundle.getString("author.prefix");

            window.alert("Missing author prefix 'author.prefix' in ''");

        var loc = window.content.location;
        var path = "";

        if(loc.pathname.indexOf("/cf") == 0){
            path = loc.pathname + loc.hash +;
            path = "/cf#" + loc.pathname +;

        window.content.location.href = hostPrefix + path;

window.addEventListener("load", function(){ ExperienceAEM.AccessAndEditing.init();  }, false);

8) To build the extension, use standard jar command, at C:\dev\open-page-in-author-browser-ext

                     jar cvf eaem_access_edit.xpi -C firefox .

9) Download the extension as zip

No comments:

Post a Comment