Sonixgvn skip dark shortener

sonixgvn skip dark shortener

  1. // ==UserScript==
  2. // @name Sonixgvn skip dark shortener
  3. // @namespace https://greasyfork.org/users/821661
  4. // @match https://sonixgvn.net/*
  5. // @grant none
  6. // @version 1.0
  7. // @author hdyzen
  8. // @description sonixgvn skip dark shortener
  9. // @license GPL-3.0
  10. // ==/UserScript==
  11. 'use strict';
  12.  
  13. const decode = data => {
  14. const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  15. let o1,
  16. o2,
  17. o3,
  18. h1,
  19. h2,
  20. h3,
  21. h4,
  22. bits,
  23. i = 0,
  24. ac = 0,
  25. dec = '',
  26. tmp_arr = [];
  27. if (!data) {
  28. return data;
  29. }
  30. data += '';
  31. do {
  32. // unpack four hexets into three octets using index points in b64
  33. h1 = b64.indexOf(data.charAt(i++));
  34. h2 = b64.indexOf(data.charAt(i++));
  35. h3 = b64.indexOf(data.charAt(i++));
  36. h4 = b64.indexOf(data.charAt(i++));
  37. bits = (h1 << 18) | (h2 << 12) | (h3 << 6) | h4;
  38. o1 = (bits >> 16) & 0xff;
  39. o2 = (bits >> 8) & 0xff;
  40. o3 = bits & 0xff;
  41. if (h3 == 64) {
  42. tmp_arr[ac++] = String.fromCharCode(o1);
  43. } else if (h4 == 64) {
  44. tmp_arr[ac++] = String.fromCharCode(o1, o2);
  45. } else {
  46. tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
  47. }
  48. } while (i < data.length);
  49. dec = tmp_arr.join('');
  50. return dec;
  51. };
  52.  
  53. const linksContainer = document.getElementsByClassName('su-note')[0];
  54.  
  55. if (linksContainer) {
  56. const links = linksContainer.querySelectorAll('a[href*="/dark/?"]');
  57.  
  58. for (const link of links) {
  59. const realLink = decode(link.search.split('?')[1]);
  60.  
  61. link.href = realLink;
  62. }
  63. }