-
-
Save nucular/249ee1e3f132080cb843 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Powder Toy Undelete Removed Comments | |
// @version 1.0.1 | |
// @description Undeletes comments that have been removed, using a weird data leak. | |
// @author boxmein | |
// @namespace http://boxmein.net | |
// @run-at document-end | |
// @match http://powdertoy.co.uk/Discussions/Thread/* | |
// ==/UserScript== | |
var injected = function() { | |
$('<div class="btn btn-undelete" style="float: right; margin-top: -5px; margin-right: -32px;">Show</div>').appendTo('.Message .alert.alert-danger'); | |
$('.btn-undelete').click(function() { | |
var el = $(this).parent(); | |
var id = el.parent().attr('id').split('-')[1]; | |
try { | |
id = parseInt(id, 10); | |
} catch (err) { | |
return false; | |
} | |
// console.log('undeleting', id); | |
var req = location.pathname.replace('.html', '.json') + location.search; | |
// console.log('http request to', req); | |
$.getJSON(req).done(function(data) { | |
// console.log('received', data); | |
$.each(data.Posts, function(i, v) { | |
if (v.ID == id) { | |
console.log('found!', i, v, v.Post); | |
el.parent().html(v.Post); | |
} | |
}); | |
}); | |
}); | |
}; | |
function inject(f) { | |
var d = document.createElement('script'); | |
d.innerHTML = '('+f.toString()+')();'; | |
document.body.appendChild(d); | |
} | |
inject(injected); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment