Greasy Fork is available in English.

Reddit - View deleted content

Click on a deleted post or comment and see what was there originally

  1. // ==UserScript==
  2. // @name Reddit - View deleted content
  3. // @description Click on a deleted post or comment and see what was there originally
  4. // @author James Skinner <spiralx@gmail.com> (http://github.com/spiralx)
  5. // @namespace http://spiralx.org/
  6. // @version 3.0.0
  7. // @license MIT
  8. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAaxSURBVHhe7ZplqC1VGIav3d2t2FjY3QEG+EOxE1sMUBDzl60omOgFC+uHYmIXiih2d2N3dz7PuXvp55xZM7P32efefWBeeJgdE2vNrPXVmnGtWrVq1apVq1ZjUFPDQfAQfAN/wadwPWwOY1pTwuww09C34VoEnoG/K7gOpocxozngJHgV/oDUkR/gMTgbNoZ54G2Inc1xG0wOA6+NwOFb1okivxS+fwmnw35wCfwO8f99YKC1JvwEsdFNeRcWgqjN4DdI+7wMA6tp4E2InfoQToQ9YX9w6D8HcZ/ETlCmiyHutyAMpBy2saGPwixQpuXgToj7Lw5lctjH/daAUk1qA7F3Z6v+BJ/6t0PfhusluHXCx3+1RGdbVPH37zvbgdKsYKfTU7oH6rQ2xCerd5gOouz815D2+Q6mgoGTLi125mio02SgUYvHPQu7w4ZwJHwO8f+LYCC1L8SGbgtNtCnEkVOFrnVeyGpS2oC5OtskG9tE98GB4E2o0hewNXwy9G1A5Hx1jq4L10B8WnvAUtA0fF0PnoB4DjGKvBYauT7n1GjJOH4DsLOrgG5sAai7pp34CLT6T8HDYMJjSFymZWFl0H1+Bu7fdDR1JS2pSUqVZoC94C74FYpPp1c81x3guWeEnMwQjQ26GUlZaR92hftBP2pDTDnfh8thdUiaE06F6H5GC1Pfs2B+SNoCvEExT3AqPALetCmgVLnhOB+YTjp8c/IiV8MbcATkIjilwXodXgHj94/BjthgNS0YF2ixFwOHtU8x23D0M5wL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MPxmG4w+nQ65EaqiyBGh/EY21iZ8o5Eh0DxJph+Hga50phTaCvQDrwD8dginkujZ1a5NOTkOQ+FYupr22zLqMoiY9myl+v2ls6qFjOUVRpfWdGG+HRdFtdVLQp1Ftv/t4MXoXh97dFEeyNM9/QeFBshFh182aGX+D8nCy1HgatQZdd0ua6Jm+yrXMoaD7mXFRyOxgKu7DgFKl9UKMjM0bV9j/UcxWkXr3EpNE2ShqmJG6yTrsaGxgWUnFw81Q6Yoqa1QTti+d3Ywo67NtikQ9qKY2FEoW4/pY+24trrS49NsErlNXy5cmDlk/RtD9cY+7FcbmXYFSmNr9Our+rHFKiSHsFFTSM8t0Z7GjRXaQ1d0zqeXsWOuv6gQTPc1tLr4w2o+hLNtWrVqlWrVq1a/adx4/4BlQokldY0pQAAAAAASUVORK5CYII=
  9. // @match *://*.reddit.com/r/*/comments/*
  10. // @grant none
  11. // @run-at document-end
  12. // @require https://unpkg.com/jquery@3/dist/jquery.min.js
  13. // ==/UserScript==
  14.  
  15. /**
  16.  
  17. ## Changelog
  18.  
  19. #### 3.0.0 (28.04.2024)
  20.  
  21. * Rename script and tweak the link text for posts
  22. * Allow clicking [removed] in posts as well as comments
  23. * Fixed hover state for [removed] or [deleted] comment bodies
  24.  
  25. #### 2.4.0 (17.04.2024)
  26.  
  27. * Changed undelete source to undelete.pullpush.io
  28.  
  29. #### 2.3.0 (03.08.2022)
  30.  
  31. * Add @license field and consolidate @icon fields
  32.  
  33. #### 2.2.0 (08.06.2021)
  34.  
  35. * Replace Removeddit with Reveddit
  36.  
  37. #### 2.1.1 (07.07.2019)
  38. * Deleted comments now don't require shift-click, have hover effect
  39.  
  40. #### 2.1.0 (03.07.2019)
  41. * Shift-click on "[removed]" will open Removeddit for deleted comments
  42.  
  43. #### 2.0.0 (03.07.2019)
  44. * Add Removeddit link to post buttons at top of page
  45. * Changed name and description to match functionality
  46. * Fixed icon metadata to use optimisied Reddit logo
  47. * Minor tidying up of code
  48. * Uploaded as a new user script to Greasyfork
  49.  
  50. #### 1.2.1 (03.06.2019)
  51. * Merged with other copy of the script and updated the version to 1.2.1
  52. * Added timeout before opening Removeddit to prevent a new window being opened
  53.  
  54. #### 1.2.0 (24.05.2019)
  55. * Removed button in RES floating toolbar
  56. * Holding shift when clicking perma-link on a comment opens it in Removeddit
  57.  
  58. #### 1.1.0 (11.09.2018)
  59. * Add a "removeddit-link" to each comment
  60.  
  61. #### 1.0.0 (13.07.2018)
  62. * Switched to watcher library instead of mutation-summary
  63.  
  64. #### 0.1.0 (19.06.2018)
  65. * Initial version
  66.  
  67. ## Notes
  68.  
  69. The original user script:
  70.  
  71. https://greasyfork.org/en/scripts/370257-reddit-add-removeddit-link
  72.  
  73. */
  74.  
  75. /* jshint asi: true, esnext: true, laxbreak: true */
  76. /* global jQuery */
  77.  
  78. ; ($ => {
  79. 'use strict'
  80.  
  81. // --------------------------------------------------------------------
  82.  
  83. function getUndeleteUrl (redditUrl) {
  84. const url = new URL(redditUrl)
  85. url.host = 'undelete.pullpush.io'
  86. return url.toString()
  87. }
  88.  
  89. // --------------------------------------------------------------------
  90.  
  91. function openUndeleteSite(url) {
  92. window.setTimeout(() => {
  93. window.open(url, '_blank')
  94. }, 100)
  95. }
  96.  
  97. // --------------------------------------------------------------------
  98.  
  99. $(`.thing.link .buttons .first`).each(function () {
  100. const url = getUndeleteUrl(this.children[ 0 ].href)
  101.  
  102. $(`<li><a href="${url}" target="_blank">original post</a></li>`)
  103. .insertAfter(this)
  104. })
  105.  
  106. // --------------------------------------------------------------------
  107.  
  108. $('body')
  109. .on('click', 'a[data-event-action = "permalink"]', function (event) {
  110. if (!event.shiftKey) {
  111. return
  112. }
  113.  
  114. openUndeleteSite(getUndeleteUrl(this.href))
  115.  
  116. return false
  117. })
  118. .on('click', '.thing.deleted > .entry > .usertext', function (event) {
  119. const permalink = location.origin + $(this).closest('.thing').data('permalink')
  120.  
  121. openUndeleteSite(getUndeleteUrl(permalink))
  122.  
  123. return false
  124. })
  125. .on('click', '#siteTable .thing.deleted > .entry .usertext', function (event) {
  126. const permalink = location.origin + $(this).closest('.thing').data('permalink')
  127.  
  128. openUndeleteSite(getUndeleteUrl(permalink))
  129.  
  130. return false
  131. })
  132.  
  133. $('body').append(`
  134. <style type="text/css">
  135. .thing.deleted > .entry .usertext {
  136. cursor: pointer;
  137. }
  138. .thing.deleted > .entry .usertext:hover .usertext-body,
  139. .thing.deleted > .entry .usertext.greyed:hover .usertext-body {
  140. color: #07f;
  141. }
  142. </style>
  143. `)
  144.  
  145. })(jQuery)
  146.  
  147. jQuery.noConflict(true)