Feb 4, 2009

Google Notebook Gadget Resizer

The default height of notebook gadget is 200px , it’s too short that need often to scroll down/up , so that write a script to change the height.
image
Install Greasemonkey
https://addons.mozilla.org/en-US/firefox/addon/748
image
User Script:Google Notebook Gadget Resizer
http://userscripts.org/scripts/show/41679
image
Result:
image

Code:

// ==UserScript==
// @name          Google Notebook Gadget Resizer
// @description   To change height of gadgets in iGoogle
// @include       http://www.google.com/ig*
// @include       http://www.google.com.tw/ig*

// @author        parkghost@hotmail.com
// @version       1.0
// ==/UserScript==

// This script are working on Google notebook gadget and some similar gadgets which content type is url and not using dynamic-height feature.
//
// you can fellow below instruction to modify default height of Google notebook gadget or add more gadget to apply new height.
//
// 1.input "about:config" in url box
// 2.search "greasemonkey.scriptvals.userscripts.org/Google Notebook Gadget Resizer.oGadgets"
// 3.The properly is a array of url pattern with height that can modify of you want to.
//
// default:
// ({'http://www.google.com/notebook/ig':"600px", 'url pattern':"400px"})
//
// The url of gadget you could look at page source that place in iframe tag.(ex.http ://87.gmodules.com/ig/ifr?view=home&url=http://itszero.googlepages.com/iGoogleTVSchedule.xml&nocache=0&up_timeRange=0&up_showPrograms=6&up_fontSize=0.75&up_favoriteChannels=&up_defaultChannel=74&lang=en&country=us&.lang=en&.country=us&synd=ig&mid=87&ifpctok=-5100993727886241321&parent=http://www.google.com&extern_js=/extern_js/f/CgJlbhICdXMrMAo4ACwrMBA4ACwrMBI4ACwrMBM4ACwrMBU4ACw/GgLq_VyeDu0.js)
//
// The URL parameter is good to become a URL pattern.
// http://itszero.googlepages.com/iGoogleTVSchedule.xml

var oGadgets = {'http://www.google.com/notebook/ig':'600px','url pattern':'400px'};
var oGadgetsStr = GM_getValue('oGadgets');
if(oGadgetsStr){
 oGadgets = eval(oGadgetsStr);
}else{
GM_setValue('oGadgets',uneval(oGadgets));
}
var oFrames = document.getElementsByTagName('iframe');
for(var i=0 ; i < oFrames.length ; i++){ 
 for(var key in oGadgets){
   var re = new RegExp(key); 
   if(re.test(oFrames[i].src)){
     oFrames[i].style.height = oGadgets[key];
   }
 }
}

Resources:

Greasemonkey Manual:API
http://wiki.greasespot.net/API_reference

Managing Gadget Height
http://code.google.com/apis/gadgets/docs/ui.html#Dyn_Height

No comments: