Last active
September 21, 2024 17:39
-
-
Save rguhr/65278c17f29cbfd97794a1389a0621da to your computer and use it in GitHub Desktop.
UserScript: Inoreader Open All Unread Articles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Inoreader Open All Unread Articles (New Design) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2.0 | |
| // @description Adds a button to open all unread articles in new tabs | |
| // @match https://*.inoreader.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=inoreader.com | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Function to open all unread articles | |
| function openAllUnread() { | |
| $(".article_unreaded .article_header_text").find("a").each(function() { | |
| window.open($(this).attr("href"), "_blank"); | |
| }); | |
| } | |
| // Function to create and add the button | |
| function addOpenAllButton() { | |
| const toolbar = document.querySelector('.inno_toolbar_button_mark_read'); | |
| if (toolbar && !document.getElementById('sb_rp_open_all')) { | |
| const openAllButton = document.createElement('div'); | |
| openAllButton.id = 'sb_rp_open_all'; | |
| openAllButton.className = 'btn-group btn-group-sm me-2'; | |
| openAllButton.innerHTML = ` | |
| <button type="button" title="Open all unread articles" class="btn btn-sm btn-outline-text flex"> | |
| <span class="h3 text-muted-color"></span> | |
| <span class="ms-1">Open all</span> | |
| </button> | |
| `; | |
| openAllButton.addEventListener('click', openAllUnread); | |
| toolbar.insertBefore(openAllButton, toolbar.firstChild); | |
| } | |
| } | |
| // Function to start observing for changes | |
| function startObserving() { | |
| const targetNode = document.body; | |
| const config = { childList: true, subtree: true }; | |
| const observer = new MutationObserver(() => { | |
| addOpenAllButton(); | |
| }); | |
| observer.observe(targetNode, config); | |
| } | |
| // Start observing as soon as the script runs | |
| startObserving(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment