🏠 Home 

Pocket - open all saves in new tab

Adds a button to open all saves in new tab, also removes all `?utm_source=*` from url


Install this script?
// ==UserScript==
// @name         Pocket - open all saves in new tab
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Adds a button to open all saves in new tab, also removes all `?utm_source=*` from url
// @author       FallenMax
// @match        https://getpocket.com/saves
// @match        https://getpocket.com/*/saves
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==
(async function() {
'use strict';
await new Promise(resolve => setTimeout(resolve, 3000))
const openAllLinks = () =>{
const links = document.querySelectorAll('.content-block[href]')
for (let i = 0; i < links.length; i++) {
const link = links[i]
const url = new URL(link.href)
url.searchParams.delete('utm_source')
link.href = url.href
link.target = '_blank'
link.click()
}
}
let $sort = document.querySelector('button[data-testid="sort-options"]')
let count=0
while (!$sort) {
if(count++>20) throw new Error('button not found')
await new Promise(resolve => setTimeout(resolve, 1000))
$sort = document.querySelector('button[data-testid="sort-options"]')
}
let $openAll = document.createElement('button')
$openAll.textContent = 'Open All'
$openAll.className = 'tiny'
$sort.insertAdjacentElement('afterend', $openAll)
$openAll.onclick = openAllLinks
})();