Skip to content

Instantly share code, notes, and snippets.

@squarestar
Last active October 7, 2022 19:54
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 squarestar/9288875 to your computer and use it in GitHub Desktop.
Save squarestar/9288875 to your computer and use it in GitHub Desktop.
Bookmarklet to resize a website's content to a centred, 960px-wide main column.
(function() {
if(document.querySelector('#wrap960') ) return;
var content = document.body.innerHTML;
var wrap = document.createElement('div');
wrap.setAttribute('id','wrap960');
wrap.setAttribute('style','position:relative;width:960px;margin:auto;');
wrap.innerHTML = content;
document.body.innerHTML = '';
document.body.appendChild(wrap);
})();
/* Minified */
(function(){if(document.querySelector('#wrap960'))return;var content=document.body.innerHTML;var wrap=document.createElement('div');wrap.setAttribute('id','wrap960');wrap.setAttribute('style','position:relative;width:960px;margin:auto;');wrap.innerHTML=content;document.body.innerHTML='';document.body.appendChild(wrap);})();
@squarestar
Copy link
Author

To use, add the code below to a new bookmark:
javascript:(function(){if(document.querySelector('#wrap960'))return;var%20content=document.body.innerHTML;var%20wrap=document.createElement('div');wrap.setAttribute('id','wrap960');wrap.setAttribute('style','position:relative;width:960px;margin:auto;');wrap.innerHTML=content;document.body.innerHTML='';document.body.appendChild(wrap);})();

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