Sleazy Fork is available in English.

Soyjak.Party Filename Randomizer

Rename uploaded images and videos with random filenames

  1. // ==UserScript==
  2. // @name Soyjak.Party Filename Randomizer
  3. // @namespace datamining
  4. // @version 1.0
  5. // @description Rename uploaded images and videos with random filenames
  6. // @include https://soyjak.party/static/front-page/soyberg.png
  7. // @license MIT
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function generateRandomString(length) {
  16. const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  17. let randomString = '';
  18. for (let i = 0; i < length; i++) {
  19. const randomIndex = Math.floor(Math.random() * characters.length);
  20. randomString += characters.charAt(randomIndex);
  21. }
  22. return randomString;
  23. }
  24.  
  25. function renameFileInput(input) {
  26. if (input && input.files.length > 0) {
  27. const file = input.files[0];
  28. const extension = file.name.split('.').pop().toLowerCase();
  29. const randomString = generateRandomString(10);
  30. let newName = '';
  31.  
  32. if (['jpeg', 'png', 'gif', 'jpg'].includes(extension)) {
  33. newName = 'IMG_' + randomString + '.' + extension;
  34. } else if (['mp4', 'mkv', 'webm', 'mov', 'wmv'].includes(extension)) {
  35. newName = 'VID_' + randomString + '.' + extension;
  36. }
  37.  
  38. if (newName) {
  39. Object.defineProperty(file, 'name', {
  40. value: newName,
  41. writable: true,
  42. });
  43. }
  44. }
  45. }
  46.  
  47.  
  48. const fileInputs = document.querySelectorAll('input[type="file"]');
  49. if (fileInputs) {
  50. fileInputs.forEach(input => {
  51. input.addEventListener('change', () => {
  52. renameFileInput(input);
  53. });
  54. });
  55. }
  56. })();