Skip to content

Instantly share code, notes, and snippets.

@SourceCode
Last active January 6, 2023 23:04
Show Gist options
  • Save SourceCode/fd45011a74ae0c139d293979000d85aa to your computer and use it in GitHub Desktop.
Save SourceCode/fd45011a74ae0c139d293979000d85aa to your computer and use it in GitHub Desktop.
Creates a new window and select URLs by filter and write to list in window
// Run once in the console per page session
const NewWindow = window.open("NEW_LIST");
// Run each time to scrape URLS - they will be added to the window opened during the first run
// Replace foo.bar/baz with your filter
var x = document.querySelectorAll("a"), u = "foo.bar/baz", a = [];
for (let i = 0; i < x.length; i++) a.push([x[i].textContent.replace(/\s+/g, ' ').trim(), x[i].href]);
function g(f) {
let t = '';
for (let i = 0; i < a.length; i++) if (a[i][1].includes(f)) t += a[i][1] + '\n';
NewWindow.document.write('<pre>' + t);
}
g(u);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment