Skip to content

Instantly share code, notes, and snippets.

@berdario
Created July 26, 2011 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berdario/1107041 to your computer and use it in GitHub Desktop.
Save berdario/1107041 to your computer and use it in GitHub Desktop.
fbchatfix chrome userscript
// ==UserScript==
// @name fbchatfix
// @match http://*.facebook.com/*
// @match https://*.facebook.com/*
// ==/UserScript==
function addfix() {
var script = document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("src", "//www.bigspeedpro.com/images/partners/facebookjs/OrderedFriendsListPlus.js");
window.setTimeout(function(){document.getElementsByTagName('head')[0].appendChild(script);}, 1500);
}
addfix();
@berdario
Copy link
Author

for an old userscript I've done I used .addEventListener('load', fun, false) on an element inside <body> to make sure that the code was loaded only after that the page has been fully loaded, but unfortunately it seems that this doesn't work anymore in the last versions of chrome

thus, to avoid getting a ReferenceError on AvailableList I used a simple setTimeout as a quick&dirty solution.... the 1.5 seconds may need to be tweaked according to the connection speed

also: this code is basically the same as the bookmarklet, but I removed the .getTime... I assume that was used to avoid an old version of the code getting cached... I don't know how bigspeedpro.com is configured and how often this code is updated (not very often I hope), if it's a problem the .getTime may be needed to be added again

as I said this is very quick & dirty, and having an extension installed that constantly fetches code from some 3rd party may be a security issue (so it may be better to include the code directly in the userscript... but then it would be an hassle to update)... but then again: I don't expect the current version of the facebook chat to be around here for very long

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