Blox CMS Live / Preview Mode Switcher


This bookmarklet is for Blox CMS users. It goes in your web browser's Bookmarks Toolbar, or elsewhere in your Bookmarks menu. It lets you quickly switch between the Live and Preview modes of URLs on your site.


This bookmarklet requires you to have administrative access to the site on which you use it. If you attempt to access the Preview mode of a URL, you will be prompted to log in to Blox CMS, if you are not logged in already.

How to install

Drag the bookmarklet below onto your browser's Bookmarks Toolbar. It will create a new bookmark there. Then go to an Article or Collection in Blox to test it out!

[Blox L-P]


var thisURL = window.location.href;
if (thisURL.indexOf('admin-') != -1) {
    var serverAddressRegex = new RegExp('https:\/\/admin-([a-zA-z0-9]*)\/');
    var serverAddress = thisURL.match(serverAddressRegex);
    thisURL = thisURL.replace(serverAddress[0], 'http://www.');
    var previewTimeRegex = new RegExp('\/site\/([a-zA-z0-9%:-]*)\/-\/');
    var previewTime = thisURL.match(previewTimeRegex);
    if (previewTime) {
        thisURL = thisURL.replace(previewTime[0], '/site/-/')
    thisURL = thisURL.replace('tncms/admin/action/main/preview/site/', '');
    thisURL = thisURL.replace('/-/', '/')
} else {
    var pageSource = document.documentElement.innerHTML;
    var serverLocationRegex = new RegExp('stats-([a-zA-z0-9]*)\/');
    var serverLocation = pageSource.match(serverLocationRegex);
    var liveSiteRegex = new RegExp('https?://www.([a-zA-z0-9-]*).com');
    var liveSite = thisURL.match(liveSiteRegex);
    var adminURL = 'https://admin-' + serverLocation[1] + '' + liveSite[0] + '/tncms/admin/action/main/preview/site';
    var adminURL = adminURL.replace('http://www.', '');
    var adminURL = adminURL.replace('https://www.', '');
    var thisURL = thisURL.replace(liveSite[0], adminURL);
    if (thisURL.indexOf('.html') == -1) {
        thisURL = thisURL.replace('site/', 'site/-/')
window.location.href = thisURL;

← Home