Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p>
- <a id="bookmarklet" href="javascript:(function(){
- /*
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.*/
- scriptName = 'Reddit Restore (1.1) by /u/SuperConductiveRabbi';
- apiJSON = null;
- dupeJSON = null;
- ready = false;
- dupePosts = [];
- dupeHashSet = {};
- apiPosts = [];
- foundDeletion = false;
- deletionCount = 0;
- error = false;
- apiURL='https://www.reddit.com/api/info.json?url='+escape($('.link .entry .title a:first').attr('href'));
- dupeURL=$('.choice:contains(other discussions)').attr('href') + '.json';
- var printQuitMessage = function() {
- console.log('\n\n**** Script ending ****');
- };
- var nextStep = function() {
- if (apiJSON && dupeJSON) {
- ready = true;
- /* Originating duplicate */
- thePost = dupeJSON[0].data.children[0].data;
- if (thePost.author != '[deleted]') {
- dupePosts.push(thePost);
- dupeHashSet[thePost.id] = 1;
- }
- for (var i=0; i<dupeJSON[1].data.children.length; ++i) {
- thePost = dupeJSON[1].data.children[i].data;
- if (thePost.author != '[deleted]') {
- dupePosts.push(thePost);
- if (dupeHashSet[thePost.id]) {
- dupeHashSet[thePost.id] += 1;
- } else {
- dupeHashSet[thePost.id] = 1;
- }
- }
- }
- for (var i=0; i<apiJSON.data.children.length; ++i) {
- thePost = apiJSON.data.children[i].data;
- if (thePost.author != '[deleted]') {
- apiPosts.push(thePost);
- if (!dupeHashSet[thePost.id]) {
- foundDeletion = true;
- deletionCount++;
- var date = new Date(thePost.created_utc * 1000);
- console.log('Deletion detected!\n\tSubreddit: ' + thePost.subreddit + '\n\tDate: ' + date + '\n\tPermalink: \n\thttps://np.reddit.com' + thePost.permalink);
- }
- }
- }
- if (foundDeletion) {
- alert(deletionCount + ' deletions found! Check the JavaScript console for information (F12)\n\n' + scriptName);
- } else {
- message = 'No deletions found.\n\nRemember to run this from the thread you wish to check!';
- alert(message);
- console.log(message);
- }
- printQuitMessage();
- }
- };
- console.log('\n\n**** Script running ****');
- console.log(scriptName);
- console.log('************************');
- /* Goes from other discussions to the first off-subreddit result, then gets THAT other discussions tab
- * This allows it to check to see if the origniating post was removed*/
- if (dupeURL != 'undefined.json' ) {
- $.ajax({
- dataType: 'json',
- url: dupeURL,
- }).then(function(data) {
- if(data.length > 1 && data[1].data.children.length >= 1) {
- re = /\/comments\//;
- newURL = 'https://www.reddit.com' + data[1].data.children[0].data.permalink.replace(re, '/duplicates/') + '.json';
- $.ajax({
- dataType: 'json',
- url: newURL,
- }).then(function(data) {
- dupeJSON = data;
- nextStep();
- })
- .fail(function() { printQuitMessage(); });
- } else {
- message = 'Sorry, but this script only works if a post has at least one result in the Other Discussions tab.';
- console.log(message);
- alert(message);
- printQuitMessage();
- }
- })
- .fail(function() { printQuitMessage(); });
- } else {
- message = 'Sorry, but this script only works if a post has at least one result in the Other Discussions tab.';
- console.log(message);
- alert(message);
- printQuitMessage();
- }
- $.ajax({
- dataType: 'json',
- url: apiURL,
- }).then(function(data) {
- apiJSON = data;
- nextStep();
- });
- }());">Reddit Restore</a>
- </p>
- <p>
- Reddit Restore checks for deletions on Reddit. Drag the above link into your bookmarks toolbar to install it.</p><p>v1.1 <a href="https://www.reddit.com/u/SuperConductiveRabbi">/u/SuperConductiveRabbi</a>
- <ul>
- <li>Visit the comments section of a Reddit post you wish to check</li>
- <li>Click "Reddit Restore" in your bookmarks toolbar</li>
- <li>Wait a few seconds for a pop-up and/or check the Javascript console (F12) then "Console"</li>
- </ul>
- <p>This script currently requires that the post has at least one "other discussion" listed. If you see "Other discussions (1)" or greater, it should work!</p>
- <p>
- Stay tuned to <a href="https://www.reddit.com/r/undelete">/r/undelete</a> for new versions or bug fixes.
- </p>
- <p>Thanks to <a href="https://www.reddit.com/u/go1dfish">/u/go1dfish</a> for the JS help and for his tireless work to make censorship and removals more transparent on Reddit</p>
- <p>Code licensed under the GPL</p>
- </ul>
- </p>
Add Comment
Please, Sign In to add comment