Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.