Skip to content

Instantly share code, notes, and snippets.

@nucular
Forked from boxmein/undelete.user.js
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucular/249ee1e3f132080cb843 to your computer and use it in GitHub Desktop.
Save nucular/249ee1e3f132080cb843 to your computer and use it in GitHub Desktop.
// ==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