RSS Feed Extractor

Estrae il feed RSS di una pagina web

  1. // ==UserScript==
  2. // @name RSS Feed Extractor
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Estrae il feed RSS di una pagina web
  6. // @author Magneto1
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant GM_registerMenuCommand
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Funzione per estrarre il feed RSS
  16. const extractRSSFeed = () => {
  17. // Cerca i link al feed RSS nella pagina
  18. const links = document.querySelectorAll('link[type="application/rss+xml"], link[type="application/atom+xml"]');
  19. if (links.length > 0) {
  20. // Se trova almeno un link, mostra il primo in un alert
  21. const rssFeedUrl = links[0].href;
  22. alert(`Feed RSS trovato: ${rssFeedUrl}`);
  23. } else {
  24. alert('Nessun feed RSS trovato in questa pagina.');
  25. }
  26. };
  27.  
  28. // Aggiungi un comando al menu di Violentmonkey per estrarre il feed RSS
  29. GM_registerMenuCommand("Estrai Feed RSS", extractRSSFeed);
  30. })();