Volafile Unremover

Preserves messages and files auto-removed by Volafile and prevents navigation to front page on room closure.

  1. // ==UserScript==
  2. // @name Volafile Unremover
  3. // @author Arnold François Lecherche and a Vola anon named Adonis
  4. // @namespace greasyfork.org
  5. // @icon https://volafile.org/favicon.ico
  6. // @version 1.09
  7. // @description Preserves messages and files auto-removed by Volafile and prevents navigation to front page on room closure.
  8. // @include http://volafile.org/*
  9. // @include http://*.volafile.org/*
  10. // @include https://volafile.org/*
  11. // @include https://*.volafile.org/*
  12. // @grant none
  13. // @run-at document-end
  14. // @copyright 2020 Arnold François Lecherche
  15. // ==/UserScript==
  16. (function (w, d) {
  17. 'use strict';
  18. var e, v, c, g;
  19. function removeMessages(t) {
  20. var obj = ['messages', 'queued_messages'], i = obj.length, msg, j;
  21. while (i--) {
  22. msg = c[obj[i]];
  23. j = msg.length;
  24. while (j--) if (t.msgIds.indexOf(msg[j].data.id) !== -1) {
  25. msg[j].elem.style.opacity = '.4';
  26. msg[j].elem.style.textDecoration = 'line-through';
  27. }
  28. }
  29. }
  30. function delete_file(t) {
  31. var file = e.filelist.files_by_id[t];
  32. file.dom.fileElement.style.opacity = '.2';
  33. file.dom.fileElement.getElementsByTagName('a')[0].style.textDecoration = 'line-through';
  34. c.showMessage('YourMom', 'File deleted: ' + file.name + ' [' + JSON.stringify(file.tags) + ']', {'dontsave': true, 'staff': true});
  35. }
  36. function navigate(e) {
  37. c.showMessage('Script', 'Intercepted auto-navigation to "' + e + '".', {'dontsave': false, 'staff': true});
  38. }
  39. function reload(e) {
  40. c.showMessage('Script', 'Intercepted force-reload.', {'dontsave': true, 'staff': true});
  41. }
  42. function config(t) {
  43. var keys = Object.keys(t), old = (keys.length === 1 && w.config[keys[0]]) ? ' from {"' + keys[0] + '":' + JSON.stringify(w.config[keys[0]]) + '} ' : '';
  44. if (keys.length < 20) c.showMessage('Config', 'changed ' + old + 'to ' + JSON.stringify(t), {'dontsave': true, 'staff': true});
  45. g(t);
  46. }
  47. function init() {
  48. var n;
  49. e = w.RoomInstance.extensions;
  50. n = e.connection;
  51. n.navigate = navigate;
  52. v = n._events;
  53. v.removeMessages = removeMessages;
  54. v.delete_file = delete_file;
  55. v.forceReload[0] = reload;
  56. g = v.config;
  57. v.config = config;
  58. c = e.chat;
  59. c.showMessage('Script', 'Volafile spy mode', {'dontsave': true, 'staff': true});
  60. }
  61. w.addEventListener('load', init, false);
  62. })(window, document);