FarmVille View Simplifier

By JoeSimmons Last update Oct 3, 2010 — Installed 29,162 times.

There are 10 previous versions of this script.

// ==UserScript==
// @name           FarmVille View Simplifier
// @namespace      http://userscripts.org/users/23652
// @description    Gives you the ability to clean the page of everything but the game and menu
// @include        http://apps.facebook.com/onthefarm/*
// @copyright      JoeSimmons
// @version        1.0.6
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// @require        http://userscripts.org/scripts/source/51532.user.js
// ==/UserScript==

var menu = true; // True = shows menu
				 // False = hides menu

var addStyle = function(css) {
        var head = document.getElementsByTagName('head')[0], style = document.createElement('style');
        if (!head) {return}
        style.type = 'text/css';
		style.id = 'fv_simplify_style';
        try {style.innerHTML = css} catch(x) {style.innerText = css}
        head.appendChild(style);
    }

// Create by avg, modified by JoeSimmons
function create(a,b) {
	var ret=document.createElement(a);
	if(b) for(var prop in b) {
		if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false);
		else if(prop=="kids" && (prop=b[prop])) {
			for(var i=0;i<prop.length;i++) ret.appendChild(prop[i]);
		}
		else if('style,accesskey,id,name,src,href,class'.indexOf(prop)!=-1) ret.setAttribute(prop, b[prop]);
		else ret[prop]=b[prop];
	}  return ret;
}

// Hide by JoeSimmons
// Syntax: hide('gbar');
function hide(e) {
var node=(typeof e=='string')?document.getElementById(e):((typeof e=='object')?e:false);
if(node && node.style) node.style.display='none';
}

// Show by JoeSimmons
// Syntax: show('gbar');
function show(e) {
var node=(typeof e=='string')?document.getElementById(e):((typeof e=='object')?e:false);
if(node && node.style) node.style.display='';
}

function toggle() {
GM_setValue("fv_simplify_on", (GM_getValue("fv_simplify_on", false)?false:true));
$g("#fv_simplify_toggle_button").value = "FarmVille Simplify ["+(GM_getValue("fv_simplify_on", false)?"on":"off")+"]";
main();
}

function main() {

if(!$g(".//iframe[contains(@src,'farmville.com/flash')]", {type:9,node:$g("#app_content_102452128776")})) return;

if(!$g("#fv_simplify_toggle_button")) document.body.appendChild(create("input", {type:"button",value:"FarmVille Simplify ["+(GM_getValue("fv_simplify_on", false)?"on":"off")+"]",id:"fv_simplify_toggle_button",style:"position:fixed; bottom:42px; right:8px;",onclick:toggle}));

var css=<><![CDATA[
.UIStandardFrame_Container, .UIStandardFrame_Content, .tabs {
border: 0 !important;
display: block !important;
margin: 0 0 0 6% !important;
padding: 0 !important;
width: auto !important;
height: auto !important;
}

#app_content_102452128776 iframe {
padding: 0 !important;
}

#app_content_102452128776>div>div>*:not([class="tabs clearfix"]):not([class*="fb_protected_wrapper"]), #pagefooter, #menubar_container, #promoBarIframe {
display:none !important;
}
]]></>.toString();
if(menu) {
css=css.replace(/, #menubar_container/, "");
css+="\n\n.toggle_tabs {\npadding:4px 0 4px 0 !important;\n}";
}

if(GM_getValue("fv_simplify_on", false)) addStyle(css);
	else $g("#fv_simplify_style", {del:true});
}

window.addEventListener('load', main, false);

GM_addStyle("*[id*=\"ad_ctr\"], .UIStandardFrame_SidebarAds {display:none !important;}");