Last active
August 29, 2015 14:01
-
-
Save aggieben/2d09cecafec5cbb784ca to your computer and use it in GitHub Desktop.
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 Show Deleted Chat Messages | |
// @namespace https://gist.github.com/aggieben | |
// @version 0.2.2 | |
// @description show deleted messages on chat.*.stackexchange.com and chat.(*.\.)stackoverflow.com | |
// @match *://chat.meta.stackexchange.com/* | |
// @match *://chat.stackexchange.com/* | |
// @match *://chat.stackoverflow.com/* | |
// @copyright 2012+, Ben Collins | |
// ==/UserScript== | |
function with_jquery(f) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.textContent = "(" + f.toString() + ")(jQuery)"; | |
document.body.appendChild(script); | |
}; | |
with_jquery(function($){ | |
$sidebar_widgets = $('#widgets'); | |
if ($sidebar_widgets.length == 0) { | |
$('#sidebar-content').append($('<div id="widgets"></div>')); | |
} | |
$sidebar_widgets = $('#widgets'); | |
$link = $('<a href="#">show deleted messages</a>').on('click', function(event, data) { | |
event.preventDefault(); | |
$('.message').has('.deleted').each(function() { | |
var mid = this.id.split('-')[1]; | |
var host = window.location.host; | |
$.get('//' + host + '/messages/' + mid + '/history', function(data) { | |
$('#message-'+mid).css('color','red').html($(data).find('.message:eq(0)').html()); | |
}); | |
}); | |
}); | |
$widget = $('<div class="sidebar-widget"></div>').append($link); | |
$(function() { | |
$sidebar_widgets.append($widget); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0.2.2: updated for move from meta.so to meta.se