Last active
January 2, 2016 14:32
-
-
Save rlemon/7460953 to your computer and use it in GitHub Desktop.
WELCOME USER USERSCRIPT Yissss
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 WELCOME USER | |
// @author Robert Lemon | |
// @version 1.1 | |
// @namespace | |
// @description Adds a welcome button to the chat. | |
// @include http://chat.stackoverflow.com/rooms/* | |
// ==/UserScript== | |
function exec(fn) { | |
var script = document.createElement('script'); | |
script.setAttribute("type", "application/javascript"); | |
script.textContent = '(' + fn + ')();'; | |
document.body.appendChild(script); // run the script | |
} | |
window.addEventListener("load", function () { | |
// script injection | |
exec(function () { | |
var btn = $('<button class="button" style="margin-left: 2px;">Welcome</button>'), | |
room = document.forms[0].elements.room.value; | |
btn.on('click', function () { | |
var modal = $('<div><h4>Welcome Whom?</h4></div>'), | |
$users = $('#present-users:not(.more)').clone(); | |
modal.append($users).addClass('popup room-popup').css({ | |
bottom: btn.position().top, | |
left: btn.position().left | |
}).on('click', function (e) { | |
if( e.target.className === 'more' ) { | |
return; | |
} | |
$('#input').val("@" + (e.target.title.replace(/ /g, '')) + " Welcome to the " + $('#roomname').text() + " chat! " + $('#roomdesc').text()); | |
$('#sayit-button').click(); | |
modal.remove(); | |
return false; | |
}); | |
$(document.body).append(modal); | |
return false; | |
}); | |
$('#chat-buttons').append(btn); | |
}); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment