Skip to content

Instantly share code, notes, and snippets.

@boxmein
Last active August 14, 2017 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boxmein/06651fcb0e9503924ba9 to your computer and use it in GitHub Desktop.
Save boxmein/06651fcb0e9503924ba9 to your computer and use it in GitHub Desktop.
An userscript that un-deletes forum posts on http://powdertoy.co.uk. To run, save as file and drag into extensions folder (Chrome) or use an addon (GreaseMonkey for Firefox, TamperMonkey for Mozilla). http://puu.sh/fHN7l/58ea0cde48.png THIS is what I mean by removed!
// ==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, Mrprocom
// @namespace http://boxmein.net
// @run-at document-end
// @match http://powdertoy.co.uk/Discussions/Thread/*
// ==/UserScript==
var injected = function() {
var url = window.location.href;
setInterval(function() {
if (window.location.href != url) {
url = window.location.href;
$('.Message .alert.alert-danger')
.append('<a class="btn" style="float: right; margin-top: -5px; margin-right: -32px;">Show</a>');
}
}, 100);
$('.Message .alert.alert-danger')
.append('<a class="btn" style="float: right; margin-top: -5px; margin-right: -32px;">Show</a>');
$(document).on('click', '.btn', function() {
var id = $(this).closest('.Message').attr('id').split('-')[1];
var el = $(this).parent();
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()+')();';
$("body").append('<script>('+f.toString()+')();</script>');
}
inject(injected);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment