RSS Feed Finder

Find and display RSS feed links on webpages.

当前为 2024-03-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name RSS Feed Finder
  3. // @namespace http://tampermonkey.net/
  4. // @author iamnobody
  5. // @version 1.3
  6. // @description Find and display RSS feed links on webpages.
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant GM_setClipboard
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Create and style the floating button
  16. const rssButton = document.createElement('button');
  17. rssButton.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Feed-icon.svg/20px-Feed-icon.svg.png">';
  18. rssButton.style.position = 'fixed';
  19. rssButton.style.top = '20px';
  20. rssButton.style.right = '20px';
  21. rssButton.style.backgroundColor = 'transparent';
  22. rssButton.style.border = 'none';
  23. rssButton.style.cursor = 'pointer';
  24. rssButton.style.zIndex = '9999';
  25. document.body.appendChild(rssButton);
  26.  
  27. // Function to find and display RSS feed links
  28. function findAndDisplayRSSFeeds() {
  29. const feedLinks = document.querySelectorAll('link[type="application/rss+xml"], link[type="application/atom+xml"], a[href$=".xml"]');
  30. if (feedLinks.length > 0) {
  31. const feedList = document.createElement('ul');
  32. feedList.style.listStyleType = 'none';
  33. feedList.style.backgroundColor = '#ffffff';
  34. feedList.style.padding = '10px';
  35. feedList.style.border = '1px solid #007bff';
  36. feedList.style.borderRadius = '5px';
  37. feedList.style.position = 'fixed';
  38. feedList.style.top = '50px';
  39. feedList.style.right = '20px';
  40. feedList.style.zIndex = '9999';
  41. feedLinks.forEach(link => {
  42. const listItem = document.createElement('li');
  43. listItem.textContent = link.href;
  44. feedList.appendChild(listItem);
  45. });
  46. document.body.appendChild(feedList);
  47. } else {
  48. alert('No RSS feeds found on this page.');
  49. }
  50. }
  51.  
  52. // Add click event listener to the RSS button
  53. rssButton.addEventListener('click', function() {
  54. findAndDisplayRSSFeeds();
  55. GM_setClipboard(window.location.href);
  56. alert('Link copied!');
  57. });
  58. })();