Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Langerz82/b89845c1a8b9319da5c0 to your computer and use it in GitHub Desktop.
Save Langerz82/b89845c1a8b9319da5c0 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ChatForFree Fix Resizing (Langerz31)
// @description This fixes the ChatForFree Chat Site by re-sizing the window to be within the window.
// Tested on FireFox 33.1.1.
// Chrome 39.0.2171.65
// If it's broken send me an e-mail: jdoe090910@gmail.com or
// message me on cff Langerz31.
// @namespace Langerz.ChatForFree
// @include http://mobile.chatforfree.org/index.php?do=/desktop-chat/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version 1.3.1
// @grant none
// ==/UserScript==
var nW = "100%";
var nH = "100%";
var cbl = $("#chatblazerLayer");
cbl.width(nW);
cbl.height(nH);
var cbe8 = $("#cbe8");
cbe8.width(nW);
cbe8.height(nH);
$(window).resize(function () { resizeChat(); });
$(window).load(function () { resizeChat(); });
function resizeChat() {
var windowW = $(window).width();
var windowH = $(window).height();
var adBar = $("#site_content").children('table');
var cb8embed = $("#cbe8").children('embed');
var navHdr = $("#header");
var body = $("#nb_body");
var mainpad = $("#main_content_padding");
if (windowW < 475)
{
cb8embed.width(470);
// Reduce padding to 0.
mainpad.css("padding-left", "0");
mainpad.css("padding-right", "0");
}
else
{
// main_content_padding = 15px + 15px. main_content border 2px.
cb8embed.width(windowW - 32);
// Reduce padding to 0.
mainpad.css("padding-left", "15px");
mainpad.css("padding-right", "15px");
}
if (windowH < 445)
{
cb8embed.height(440);
// Move the Nav and Ad Bar to the bottom.
adBar.insertAfter(cbl);
navHdr.insertAfter(body);
navHdr.css("position","relative");
body.css("padding-top","0");
// Reduce padding to 0.
mainpad.css("padding-top", "0");
mainpad.css("padding-bottom", "0");
}
else
{
// main_content_padding = 10px + 10px
// main_content border 1px.
// miscellaneous 4px.
// body height 40px (but used in header).
var bodyH = body.outerHeight() - body.height();
cb8embed.height(windowH - adBar.outerHeight() - bodyH - 38);
// Move the Nav and Ad Bar to the top.
adBar.insertBefore(cbl);
navHdr.insertBefore(body);
navHdr.css("position","absolute");
body.css("padding-top","40px");
// Reduce padding to 0.
mainpad.css("padding-top", "10px");
mainpad.css("padding-bottom", "10px");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment