Skip to content

Instantly share code, notes, and snippets.

@5310
Created May 17, 2013 08:01
Show Gist options
  • Save 5310/5597621 to your computer and use it in GitHub Desktop.
Save 5310/5597621 to your computer and use it in GitHub Desktop.
This quck userscript is for the I/O 2013 makeover of Google+, whose multicolumn layout I find illegible, and single column too narrow. It aims to fix the latter by widening the stream to a configurable amount, as well as tries to enlarge any post images to the best fit for the new width, and optionally allows stretching of every image to fit the…
// ==UserScript==
// @name Google+ I/O 2013 Theme Single Column Layout Widener [Configurable]
// @namespace http://5310.github.io/
// @version 0.1
// @description While the I/O 2013 makeover for G+ has been rather pretty, on the desktop, the multicolumn layout is illegible, and the single column is too narrow. This script contains styles to widen the single column layout, as well as tries to enhance any featured post images to the larger size if possible.
// @match https://plus.google.com/*
// @copyright WTFPL
// @run-at document-start
// ==/UserScript==
// CONFIGURATION //
var STREAM_WIDTH = 1000; // Desired width of the single column stream in pixels.
var IMAGE_ENLARGE = true; // Recommended: 'True' to try to enlarge any post images to the widened stream if possible. 'False' to leave images as is.
var IMAGE_STRETCH = false; // Recommended: 'False', which won't stretch low resolution images to make them look worse, instead, simply center align them. 'True' to stretch any post images to fit width, regardless of their resolution or whether it looks worse.
// SCRIPT //
// Set stream width.
GM_addStyle("\
/* Stream Channel*/\
.HTAwOd {\
width: "+STREAM_WIDTH+"px !important;\
}\
/* Post Widget*/\
.kDq7F {\
width: auto !important;\
}\
");
// Try to enlarge post images.
if ( IMAGE_ENLARGE ) {
var doBeforeLoad = function(event){
// Check for custom flag and any other criteria.
if (
!event.srcElement.dataset["redirected"] &&
event.srcElement.tagName == "IMG" /*&&
event.srcElement.classList.contains("ev") &&
event.srcElement.classList.contains("MAvK1e") &&
event.srcElement.classList.contains("lg7oNe ") */
) {
// Set a custom flag to anything true so that we don't make the same changes in an infinite loop.
event.srcElement.dataset["redirected"] = event.srcElement.src;
// Check for Google CDN image properties and change it to fit width.
var pattern = /w[0-9]*-h[0-9].*-o/g;
event.srcElement.src = event.srcElement.src.replace(pattern, "w"+(STREAM_WIDTH-14)+"-o");
}
};
document.addEventListener('beforeload', doBeforeLoad , true);
}
// Stretch post images to fit width.
if ( IMAGE_STRETCH ) {
GM_addStyle("\
/* Stretch Post Images*/\
.ev.MAvK1e.lg7oNe {\
width: "+(STREAM_WIDTH-14)+"px;\
height: auto;\
max-height: none;\
}\
");
}
@5310
Copy link
Author

5310 commented May 17, 2013

Script works in Chrome/ium just fine. But does not work in Firefox (Scriptish) for no good reason whatsoever.

Unfortunately, that is my use-case. Trying to fix.

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