Last active
August 18, 2022 07:23
-
-
Save real-jiakai/df28de88da2f1982167a497a35925e29 to your computer and use it in GitHub Desktop.
Open HackNews Letter Daily's All Links Once
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 Open HackNews Letter Daily's All Links Once | |
| // @namespace https://gist.github.com/real-jiakai/df28de88da2f1982167a497a35925e29 | |
| // @version 0.1 | |
| // @description 一次性打开hacknews daily newsletter页面的全部链接,无需再一个一个点击。请务必启用浏览器的弹出式窗口!!! | |
| // @author gujiakai | |
| // @match https://us1.campaign-archive.com/* | |
| // @match https://mail.qq.com/* | |
| // @match https://mail.google.com/* | |
| // @icon https://news.ycombinator.com/favicon.ico | |
| // @grant none | |
| // @license MIT | |
| // ==/UserScript== | |
| // 等待页面加载完毕,再执行脚本 | |
| window.addEventListener('load', function (){ | |
| 'use strict'; | |
| // 获取所有的链接 | |
| function getAllLinks(){ | |
| let textContent_links = document.getElementsByClassName("textContent link") | |
| let urls=[] | |
| for (let textContent_link of textContent_links){ | |
| let url=textContent_link.childNodes[1].childNodes[1].getAttribute('href') | |
| urls.push(url) | |
| } | |
| return urls; | |
| } | |
| // 在新窗口打开链接 | |
| function openInNewTab(url){ | |
| window.open(url,"_blank") | |
| } | |
| let urls=getAllLinks() | |
| for (let url of urls){ | |
| openInNewTab(url) | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment