Skip to content

Instantly share code, notes, and snippets.

@real-jiakai
Last active August 18, 2022 07:23
Show Gist options
  • Select an option

  • Save real-jiakai/df28de88da2f1982167a497a35925e29 to your computer and use it in GitHub Desktop.

Select an option

Save real-jiakai/df28de88da2f1982167a497a35925e29 to your computer and use it in GitHub Desktop.
Open HackNews Letter Daily's All Links Once
// ==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