Skip to content

Instantly share code, notes, and snippets.

@mishudark
Forked from mal/convore-bookmarklets.js
Created April 8, 2012 22:46
Show Gist options
  • Save mishudark/2340207 to your computer and use it in GitHub Desktop.
Save mishudark/2340207 to your computer and use it in GitHub Desktop.
Convore Usability Bookmarklets
// For use with convore.com
/*
* Automatically increase the size of the input field as you type
*/
javascript:void !function(a,b){var c=function(c){var d=$(this),e=parseInt(d.css("height")),f=c.keyCode===b||c.keyCode===13?19:this.scrollHeight,g;if(g=e-f)$("#message-list").css("margin-bottom",61+f),d.css("height",f),(g<0||a.scrollY<a.scrollMaxY)&&a.scroll(0,a.scrollY-g)};$("#footer").attr("style","height: auto !important"),$("#id-message").bind("keypress keyup",c).css("height",19),$("#post-message").find("input.btn").bind("click keyup",function(a){c.call($("#id-message"),a)})}(window)
/*
* Add permalinks to posts (click the time ago text)
* Based on previous work by balpha, https://convore.com/users/balpha/
*/
javascript:void $("#message-list").delegate("li.message:not(.perm)", "mouseenter", function(){var a=$(this).addClass("perm");a.find("abbr.timeago").wrap("<a/>").parent().css("text-decoration","none").attr("href",$("#recent-topics .active a").attr("href")+a.attr("id").replace("message-",""))})
/*
* Remove the lines between posts
* Suggested by jukkalaurila, https://convore.com/users/jukkalaurila/
*/
javascript:void !function(a){var b=$("<style>");$("head").append(b);for(x in a)a[x].href===null&&a[x].insertRule("#message-list li { border: 0 }",0)}(document.styleSheets)
// ==UserScript==
// @name Convorenient
// @description Upgrade Convore with a few extra features
// @include https://convore.com/*/*
// @author mal, https://convore.com/users/mal/
// @author balpha, https://convore.com/users/balpha/
!function()
{
var init = function ($)
{
var config = {
inputbox: true,
permalinks: true,
styles: {
'#message-list li': 'border: 0;' // remove post dividers
}
};
if ( config.inputbox )
{
var func = function(e)
{
console.log(e);
var me = $(this),
height = parseInt(me.css('height')),
newHeight = e.keyCode === undefined || e.keyCode === 13 ? 19 : this.scrollHeight,
diff;
if ( diff = height - newHeight )
{
$("#message-list").css("margin-bottom", 61 + newHeight);
me.css("height", newHeight);
if ( diff < 0 || window.scrollY < window.scrollMaxY )
window.scroll(0, window.scrollY - diff);
}
};
$("#footer").attr("style","height: auto !important");
$("#id-message").bind("keypress keyup", func).css("height", 19);
$("#post-message").find('input.btn').bind("click keyup", function(e)
{
func.call($("#id-message"), e);
});
}
if ( config.permalinks )
{
$("#message-list").delegate("li.message:not(.perm)", "mouseenter", function()
{
var post = $(this).addClass("perm");
post.find("abbr.timeago")
.wrap("<a/>")
.parent()
.css("text-decoration","none")
.attr("href",$("#recent-topics .active a")
.attr("href") + post.attr("id").replace("message-",""))
});
}
if ( config.styles )
{
var style = $("<style>"),
sheets = document.styleSheets;
$("head").append(style);
for ( x in sheets )
{
if ( sheets[x].href === null )
{
for ( rule in config.styles )
sheets[x].insertRule(rule + ' {' + config.styles[rule] + '}', 0);
break;
}
}
}
};
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