-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathChatMods.user.js
55 lines (50 loc) · 1.71 KB
/
ChatMods.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ==UserScript==
// @name Chat Mods
// @description Modifications and bug fixes for StackExchange's chat rooms
// @match *://chat.meta.stackexchange.com/*
// @match *://chat.stackexchange.com/*
// @match *://chat.stackoverflow.com/*
// @match *://chat.askubuntu.com/*
// @author @HodofHod
// @version 1.4
// ==/UserScript==
function inject(f) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.textContent = '(' + f.toString() + ')()';
document.body.appendChild(script);
};
//Makes the lower starred messages in SE chat rooms accessible.
function addScroll() {
$('#sidebar').css({
height:'auto',
bottom:$('#input-area').outerHeight(),
'overflow-y':'auto',
});
$('#my-rooms').css("margin-left", "18px")
}
//Fixes bidirectional bug in starred chat messages.
function bidi(){
reg = /[\p{InHebrew}\p{InArabic}]/;
$.each($('[id^=summary_]'), function(i, star){
reg.test($(star).html()) && $(star).html($(star).html().replace(/ - <a/, ' ‎- <a'));
});
}
function followReply(){
$('.reply-info').click(function(){
var anchor = this.href.match(/#\d+$/)[0],
msg = $('#message-' + anchor.slice(1));
if (msg.length){
this.href = anchor;
$('.highlight').removeClass('highlight');
msg.addClass('highlight');
$('html, body').animate({ scrollTop: msg.offset().top }, 'fast')
}
});
}
if (/^\/rooms\//.test(window.location.pathname)){
inject(addScroll);
inject(bidi);
}else if (/^\/transcript\//.test(window.location.pathname)){
inject(followReply);
}