Skip to content

Instantly share code, notes, and snippets.

@dennishall
Created July 28, 2011 16:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennishall/1111837 to your computer and use it in GitHub Desktop.
Save dennishall/1111837 to your computer and use it in GitHub Desktop.
Toggle the current page between author and publish mode (if the page is powered by adobe day cq)
javascript:(function(){var a=location,b=/wcmmode=disabled[&]?/,c=a.search,d=c.replace(b,""),e="wcmmode=disabled",f=a.href.replace("/cf#","").replace("?","?"+e);a.href=b.test(a.href)?location.protocol+"//"+location.host+"/cf#"+location.pathname+(d.length?"?"+d:d)+location.hash:b.test(f)?f:f+"?"+e})()
(function(){
var l = location,
re = /wcmmode=disabled[&]?/,
qs = l.search,
_qs = qs.replace(re, ''),
nowcm = 'wcmmode=disabled',
href = l.href.replace('/cf#', '').replace('?', '?' + nowcm);
//
l.href = re.test(l.href)
? location.protocol + '//' + location.host + '/cf#' + location.pathname + (_qs.length ? '?' + _qs : _qs) + location.hash
: (re.test(href) ? href : href+'?'+nowcm);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment