Skip to content

Instantly share code, notes, and snippets.

@greystate
Last active September 29, 2015 07:38
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 greystate/1567959 to your computer and use it in GitHub Desktop.
Save greystate/1567959 to your computer and use it in GitHub Desktop.
XMLDump toggle Bookmarklet
// What it does:
(function() {
var loc = document.location;
var hasXMLDump = /xmldump(\.aspx)?(\/?\?([^=&?]+=[^=&?]+&?)*)?$/i;
var hasntXMLDump = /(\/|(\.aspx))?$/i;
if (hasXMLDump.test(loc.pathname)) {
document.location = loc.pathname.replace(hasXMLDump, '$1');
} else {
document.location = loc.pathname.replace(hasntXMLDump, '/xmldump$2');
}
})()
// Minified for Copying to Bookmark URL:
javascript:(function()%20{var%20loc%20=%20document.location;var%20hasXMLDump%20=%20/xmldump(\.aspx)?(\/?\?([^=&?]+=[^=&?]+&?)*)?$/i;var%20hasntXMLDump%20=%20/(\/|(\.aspx))?$/i;if%20(hasXMLDump.test(loc.pathname))%20{document.location%20=%20loc.pathname.replace(hasXMLDump,%20%27$1%27);}%20else%20{document.location%20=%20loc.pathname.replace(hasntXMLDump,%20%27/xmldump$2%27);}})()
@greystate
Copy link
Author

I've used an uglier version of this until now, but Ole Andreas triggered my "create a nice version of this that works with or without the .aspx" reflex, when he posted a thread on our.umbraco.org: http://our.umbraco.org/projects/developer-tools/xml-dump/xmldump-feedback/27309-XMLDump-bookmarklet

@greystate
Copy link
Author

Updated hasXMLDump regex to account for QueryString params - now you can toggle XMLDump on, add a few options (xpath, media, id etc.) and then just toggle off again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment