Greasy Fork is available in English.

Remove Roblox URL Tracking

Removes the newly implemented roblox URL tracking parameters.

  1. // ==UserScript==
  2. // @name Remove Roblox URL Tracking
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Removes the newly implemented roblox URL tracking parameters.
  6. // @author ImFirstPlace
  7. // @match *://www.roblox.com/*
  8. // @match *://web.roblox.com/*
  9. // @icon https://www.google.com/s2/favicons?domain=roblox.com
  10. // @grant none
  11. // @run-at document-start
  12. // @noframes
  13. // @license GPL-3.0 License
  14. // ==/UserScript==
  15.  
  16. // For some reason userscripts run multiple times on roblox so noframes is added
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. const knownTrackingParams = [
  22. "gameSetTypeId",
  23. "homePageSessionInfo",
  24. "SearchId",
  25. "gameSearchSessionInfo"
  26. ]
  27.  
  28. function sanitizeURL(Url) {
  29. var urlSplit = Url.split("?")
  30. if (urlSplit.length >= 2) {
  31. const urlParams = new URLSearchParams(Url)
  32.  
  33. // Game referring
  34. if (Url.includes("refer?") && urlParams.has("PlaceId")) {
  35. return `https://www.roblox.com/games/${urlParams.get("PlaceId")}`
  36. }
  37.  
  38. // Library referring
  39. if (urlSplit[0].includes("/library/refer")) {
  40. const slashSplit = urlSplit[0].split("/")
  41. return `https://www.roblox.com/library/${slashSplit[5]}`
  42. }
  43.  
  44. // General parameters
  45. for (const param of knownTrackingParams) {
  46. if (urlSplit[1].includes(param)) { // urlParams.has seems to not work with the homePageSessionInfo param
  47. return urlSplit[0]
  48. }
  49. }
  50. }
  51. return false // Don't bother setting the url exact same thing!
  52. }
  53.  
  54. function handleClick(e) {
  55. var a = e.target;
  56.  
  57. while (a && !a.href) {
  58. a = a.parentElement;
  59. }
  60.  
  61. if (!a) {
  62. return;
  63. }
  64.  
  65. var realUrl = sanitizeURL(a.href)
  66. if (realUrl) {
  67. a.href = realUrl
  68. }
  69. }
  70. document.addEventListener('click', handleClick, true);
  71. document.addEventListener('mousedown', handleClick, true);
  72. document.addEventListener('touchstart', handleClick, true);
  73. })();