View Single Post
Shanezlar's Avatar
Posts: 38 | Thanked: 67 times | Joined on Oct 2009 @ Allemagne
#17
My previous script made the site hard to read in portrait mode (one handed use), so I wrote a gm-script that is aware of the current orientation.

Furthermore you can now specify some variables in 'about:config' (read the warning there) under greasemonkey.scriptvals.body_width_extender. They are:
-"minWidth": desired minimum width in pixels for the pages where this script is active (default: 1050)
-"applyInLandscapeMode": whether it should be applied while in landscape mode (default: true)
-"applyInPortraitMode": same as above for portrait mode (default: false)

For those interested:
Code:
// Minimum body width extender
// greasemonkey script
// ----------------------------------------------------------------
//
// ==UserScript==
// @name          Body width extender
// @namespace     body_width_extender
// @description   extends the minimum body width on talk.maemo.org to 1050 pixels
// @include       http://talk.maemo.org/*
// ==/UserScript==


var originalMinWidth = document.body.style.minWidth;
var desiredMinWidth = GM_getValue("minWidth",-1);

if(desiredMinWidth == -1)
{
	GM_setValue("minWidth","1050");
        desiredMinWidth = 1050;

        GM_setValue("applyInLandscapeMode", true);
	GM_setValue("applyInPortraitMode", false);
}

checkMinWidthForCurrentWindow();
window.addEventListener('resize', checkMinWidthForCurrentWindow, false);

function checkMinWidthForCurrentWindow()
{
	if((isInLandscape() && GM_getValue("applyInLandscapeMode")) || (!isInLandscape() && GM_getValue("applyInPortraitMode"))) 
	{
		document.body.style.minWidth=desiredMinWidth+"px";
	}
	else
	{
		document.body.style.minWidth=originalMinWidth;
	}
}

function isInLandscape()
{
  if(screen.width==480) return false
  else return true;
}
 

The Following 6 Users Say Thank You to Shanezlar For This Useful Post: