Mega URL Changer

Change Mega.nz URL format

  1. // ==UserScript==
  2. // @name Mega URL Changer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4
  5. // @description Change Mega.nz URL format
  6. // @author GhostySS
  7. // @match https://mega.nz/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Get the current URL
  16. var currentUrl = window.location.href;
  17.  
  18. // Check if it's a Mega.nz file URL
  19. if (currentUrl.match(/^https:\/\/mega\.nz\/file\/.*$/)) {
  20. // Extract the key from the URL
  21. var key = currentUrl.split('#')[1];
  22.  
  23. // Extract the file identifier from the URL
  24. var fileIdentifier = currentUrl.split('/')[4];
  25.  
  26. // Create the new URL format
  27. var newUrl = 'https://mega.nz/embed/' + fileIdentifier + '#' + key;
  28.  
  29. // Redirect to the new URL
  30. window.location.href = newUrl;
  31. }
  32. })();