commit 1842ab48e290c62b0fbb58c1c89fff784d7527e6
Author: Charles E. Lehner <[email protected]>
Date:   Thu Jul 16 20:30:46 2020 -0400

    Update surf feeds detection script
    
    - Don't wait for DOMContentLoaded.  Scripts now run after DOM content is
      already loaded.
    - Remove duplicate feed links
    - Hide feed count if there is only one
    - Note installation procedure
    - Update author name and link

diff --git a/surf.suckless.org/files/feeds/index.md 
b/surf.suckless.org/files/feeds/index.md
index 5e2780b8..9c2cf598 100644
--- a/surf.suckless.org/files/feeds/index.md
+++ b/surf.suckless.org/files/feeds/index.md
@@ -8,17 +8,18 @@ This script looks for links to RSS or Atom feeds in the 
current web page. If it
 finds feeds, it places an icon in the corner of the page which toggles showing
 a list of the feeds.
 
+To install, put the code in `~/.surf/script.js`
+
 Author
 ------
 
-Charles Lehner <http://celehner.com>
+Charles E. Lehner <https://celehner.com/>
 
 Code
 ----
 
-       document.addEventListener('DOMContentLoaded', function fn() {
-               document.removeEventListener('DOMContentLoaded', fn, true);
-
+       (function () {
+               var urls = {}
                var feeds = [].slice.call(document.querySelectorAll(
                        "link[href][rel~=alternate][type$=xml]," +
                        "   a[href][rel~=alternate][type$=xml]"))
@@ -28,6 +29,9 @@ Code
                                        title: el.title || document.title,
                                        type: /atom/i.test(el.type) ? 'Atom' : 
'RSS'
                                };
+                       }).filter(function (feed) {
+                               if (urls[feed.href]) return false
+                               return urls[feed.href] = true
                        });
                if (!feeds.length) return;
 
@@ -80,11 +84,13 @@ Code
                        'BDQKRhAOsbICNEEAOw==';
                toggleLink.appendChild(img);
 
-               toggleLink.appendChild(document.createTextNode(feeds.length));
+               if (feeds.length > 1) {
+                       
toggleLink.appendChild(document.createTextNode(feeds.length));
+               }
 
                function toggleFeedList(e) {
                        e.preventDefault();
                        feedList.style.display = (feedList.style.display == 
'none') ?
                                'inline-block' : 'none';
                }
-       }, true);
+       })();


Reply via email to