Created
June 19, 2014 09:29
-
-
Save fredley/e4a51ac50b98e8f580d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ChatSEy | |
// @description Nicer Mobile Chat | |
// @version 1.0 | |
// @include http://chat.meta.stackoverflow.com/rooms/* | |
// @include http://chat.stackexchange.com/rooms/* | |
// @include http://chat.stackoverflow.com/rooms/* | |
// @include http://chat.askubuntu.com/rooms/* | |
// @run-at document-end | |
// ==/UserScript== | |
var init = function($){ | |
$(document).ready(function(){ | |
window.isMobile = function(){ | |
return ($("#header").length == 1); | |
}; | |
window.inChat = function(){ | |
return ($('#chat-body').length > 0); | |
}; | |
window.setTheme = function(theme){ | |
if(!inChat()){ return; } | |
$('body').removeClass(); | |
$('body').addClass(theme); | |
if(isMobile()){ | |
$('body').addClass('mob'); | |
} | |
}; | |
var URL_ROOT = "http://chatsey.s3-website-eu-west-1.amazonaws.com/remote/v1/"; | |
var addScript = function(url){ | |
var script = $('<script/>'); | |
script.attr('type','text/javascript'); | |
script.attr('src',url); | |
$('head').append(script); | |
} | |
var addStyle = function(url){ | |
var style = $('<link/>'); | |
style.attr('rel','stylesheet'); | |
style.attr('href',url); | |
$('head').append(style); | |
} | |
if(isMobile()){ | |
addStyle(URL_ROOT + 'mobile.css'); | |
addScript(URL_ROOT + 'livequery.js'); | |
addScript(URL_ROOT + 'mobile.js'); | |
addStyle(URL_ROOT + 'themes.css'); | |
} | |
}); | |
}; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.textContent = '(' + init.toString() + ')(jQuery)'; | |
document.body.appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment