Last active
December 24, 2015 01:39
-
-
Save cnicodeme/6725674 to your computer and use it in GitHub Desktop.
Switch the Cryptocat discussion page from fixed layout to full width layout :)
This file contains hidden or 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
// Inject css rules in Cryptocat conversation for a full width display | |
// Also add a "body click to text focus" action (using jQuery, already embedded in Cryptocat) | |
// Note: Only tested on IE 6 ! (Ok, I'm kidding, only Chrome) | |
// Author : Cyril N. | |
(function (){ | |
var newcss = "#userInput>#userInputText {width : 84%;} body>div#bubble {width : auto; margin : 0 auto; position : absolute; top : 0; bottom : 0; left : 0; right : 0; height : auto; border-radius: 0}"; | |
newcss += "div#conversationWindow .line1, div#conversationWindow .line2, div#conversationWindow .line3, div#conversationWindow .line4 {max-width : 96%;}"; | |
newcss += "div#buddyWrapper {width : 14%;}"; | |
newcss += "div#buddyList {width : 100%; overflow-y : hidden;}"; | |
console.log (newcss); | |
if ('\v'=='v') /* ie only */ { | |
document.createStyleSheet().cssText = newcss; | |
} else { | |
var tag = document.createElement('style'); tag.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(tag); | |
tag[ (typeof document.body.style.WebkitAppearance=='string') /* webkit only */ ? 'innerText' : 'innerHTML'] = newcss; | |
} | |
document.getElementById("bubble").style.marginTop = 0; | |
$('#bubble').on ('click', function() { | |
var text = ""; | |
if (window.getSelection) { | |
text = window.getSelection().toString(); | |
} else if (document.selection && document.selection.type != "Control") { | |
text = document.selection.createRange().text; | |
} | |
if (text != "") { | |
return ; | |
} | |
$('#userInputText').trigger('focus'); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And here's the bookmarklet :