[Flightradar24] Combo FlightRadar24 Script

Removes the Ad Container on the bottom right of the FlightRadar24 page and removes the 30 minute timeout.

当前为 2024-07-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name [Flightradar24] Combo FlightRadar24 Script
  3. // @namespace HKR
  4. // @match https://www.flightradar24.com/*
  5. // @grant none
  6. // @version 1.2
  7. // @license MIT
  8. // @author Bruna
  9. // @description Removes the Ad Container on the bottom right of the FlightRadar24 page and removes the 30 minute timeout.
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. const myTimeout = setTimeout(begin, 1000);
  14.  
  15. function begin() {
  16. const ad = document.getElementById("primisAdContainer");
  17.  
  18. ad.remove();
  19. }
  20. function modifyConfigString(configStr, key, value) {
  21. let regex = new RegExp(`("${key}":\\s*)[^,]+`, 'g');
  22. let newConfigStr = configStr.replace(regex, `$1${value}`);
  23. return newConfigStr;
  24. }
  25. function patchNode(node) {
  26. const changeArr = [
  27. ['map.timeout.mins', 0]
  28. // room for more changes...
  29. ];
  30. changeArr.forEach(x => node.innerText = modifyConfigString(node.innerText, x[0], x[1]));
  31. }
  32. new MutationObserver(mutationsList => {
  33. mutationsList.forEach(mutationRecord => {
  34. [...mutationRecord.addedNodes]
  35. .filter(node => node.tagName === 'SCRIPT')
  36. .forEach(node => patchNode(node));
  37. });
  38. }).observe(document, { childList: true, subtree: true });