Search code examples
facebookuserscripts

User script causes gets Facebook stuck in an endless refresh loop. How can I fix this?


I am trying to write a userscript that will remove the right panel that shows up when you play games on facebook. The idea is to get the game to take up more of the screen.

When I manually edit the page using Chrome's developer tools, there are two ways I can do this.

I can delete the element or change it's visibility to hidden. I can change the class name of the element containing it to 'clearfix' from 'clearfix hasRightColumn'.

Unfortunately, when the script is active Facebook endlessly refreshes.

I am using TamperMonkey to run the script.

// ==UserScript==
// @name       Ad-Free Facebook
// @version    0.1
// @description  Removes some ads from facebook.
// @match      https://*.facebook.com/*
// @match      http://*.facebook.com/*
// @run-at document-end
// ==/UserScript==

if (window.top != window.self)  //don't run on frames or iframes
{
    return;
}

if (window.location.host = "apps.facebook.com") {
    window.setTimeout(function(){
    document.getElementById("contentCol").classname"clearfix";
    //document.getElemenyById("rightCol").parentNode.removeChild("rightCol");
    }, 25000);
}

Solution

  • window.location.host = "apps.facebook.com" mean load "apps.facebook.com". And "apps.facebook.com" is valid to the script's @include, then loops is started....