Skip to content

Instantly share code, notes, and snippets.

@clenemt
Last active March 12, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save clenemt/8e8c1d8db9fa09df738f58ee7bbfaa25 to your computer and use it in GitHub Desktop.
Save clenemt/8e8c1d8db9fa09df738f58ee7bbfaa25 to your computer and use it in GitHub Desktop.
AEM bookmark for quick edit/preview switch
// Drops you in preview mode
javascript:(function() {
var d = document, l = d.location, s = l.search;
d.cookie = 'wcmmode=preview; path=/';
if (l.href.includes('editor.html') || !l.href.includes('wcmmode=disabled')) {
s = s.replace(/[\?&]?wcmmode=\w*/g, '');
l.href = l.origin + l.pathname.replace(/\/editor\.html/g, '') + s + (s ? '&' : '?') + 'wcmmode=disabled';
} else {
d.location.reload();
}
})();
// Drops you in edit mode
javascript:(function() {
var d = document, l = d.location, href = l.href;
d.cookie = 'wcmmode=edit; path=/';
d.cookie = 'cq-editor-layer.page=edit; path=/';
d.cookie = 'cq-editor-sidepanel=open; path=/';
if (!href.includes('editor.html') || href.includes('wcmmode=disabled')) {
href = href.replace(l.origin, l.origin + '/editor.html');
href = href.replace(/[\?&]?wcmmode=\w*/g, '');
l.href = href;
} else {
l.reload();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment