[Flightradar24] Combo FlightRadar24 Script

Changes: Removes ad container on the bottom right, Refreshes every 30 minutes to bypass 30 minute timeout, Adds the aircraft count on the title (you need the statistic widget enabled!)

  1. // ==UserScript==
  2. // @name [Flightradar24] Combo FlightRadar24 Script
  3. // @namespace HKR
  4. // @match https://www.flightradar24.com/*
  5. // @grant none
  6. // @version 1.4.1
  7. // @license MIT
  8. // @author Bruna
  9. // @description Changes: Removes ad container on the bottom right, Refreshes every 30 minutes to bypass 30 minute timeout, Adds the aircraft count on the title (you need the statistic widget enabled!)
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. // Function to remove the ad once it appears
  14. function removeAdWhenReady() {
  15. const ad = document.getElementById("primisAdContainer");
  16. if (ad) {
  17. ad.remove(); // Remove the ad if found
  18. observer.disconnect(); // Disconnect the observer once done
  19. }
  20. }
  21.  
  22. // Callback function for the observer
  23. function observeDOM() {
  24. const targetNode = document.body; // Assuming the ad container might be within the body
  25.  
  26. // Options for the observer (we want to observe child additions)
  27. const config = { childList: true };
  28.  
  29. // Create an observer instance linked to the callback function
  30. const observer = new MutationObserver(removeAdWhenReady);
  31.  
  32. // Start observing the target node for configured mutations
  33. observer.observe(targetNode, config);
  34.  
  35. // Immediately check for the ad in case it's already there
  36. removeAdWhenReady();
  37. }
  38.  
  39. // Start observing the DOM
  40. observeDOM();
  41.  
  42. // Define a function to update the document title
  43. function updateDocumentTitle() {
  44. // Assuming your HTML snippet is directly available within the document
  45. var statisticsWidget = document.querySelector('[data-widget-type="statistics"]');
  46. if (statisticsWidget) {
  47. // Find the element within the statistics widget that contains the text
  48. var textElement = statisticsWidget.querySelector('.font-normal');
  49. if (textElement) {
  50. // Get the trimmed text content of the element
  51. var textContent = textElement.textContent.trim();
  52.  
  53. // Split the text content by '/'
  54. var parts = textContent.split('/');
  55.  
  56. // Check if there are at least two parts (before and after '/')
  57. if (parts.length > 0) {
  58. // Extract the first part and remove any commas
  59. var firstNumber = parts[0].replace(',', '');
  60.  
  61. // Set the document title with the extracted number
  62. document.title = `[${firstNumber}] Flightradar24`;
  63. } else {
  64. document.title = '[Error! Check console] Flightradar24';
  65. console.error('Could not find a valid format for the text');
  66. }
  67. } else {
  68. document.title = '[Error! Check console] Flightradar24';
  69. console.error('Could not find element with class .font-normal');
  70. }
  71. } else {
  72. document.title = '[Error! Check console] Flightradar24';
  73. console.error('Could not find statistics widget. Select Widgets on the menu and enable the "Statistics" one. Upon that, go back to the app. Everything should work.');
  74. }
  75. }
  76.  
  77. // Call the function immediately to update the title initially
  78. updateDocumentTitle();
  79.  
  80.  
  81. const tillThirty = setTimeout(thirty, 1798000);
  82.  
  83. function thirty() {
  84. console.log("30 Minute time reached. Refreshing...")
  85. location.reload();
  86. }
  87.  
  88.  
  89. // Set interval to update the title every 20ms
  90. setInterval(updateDocumentTitle, 20);