Skip to content

Instantly share code, notes, and snippets.

@smarteist
Last active February 21, 2025 16:59
Show Gist options
  • Select an option

  • Save smarteist/9b49167a6d7911675f84aa5ec8512dd6 to your computer and use it in GitHub Desktop.

Select an option

Save smarteist/9b49167a6d7911675f84aa5ec8512dd6 to your computer and use it in GitHub Desktop.

Revisions

  1. smarteist revised this gist Feb 21, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions extractHrefsAsBashArray.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    (function extractHrefsAsBashArray() {
    const domain = window.location.origin;
    const domain = window.location;
    const links = document.querySelectorAll('body main.container div.list table.table tbody tr td a');
    const hrefsArray = Array.from(links).map(link => {
    const href = link.getAttribute('href');
    return href ? (href.startsWith('http') ? href : domain + href) : '';
    }).filter(href => href);
    console.log(`hrefs=( ${hrefsArray.map(href => `"${href}"`).join(' ')} )`);
    console.log(`urls=(\n ${hrefsArray.map(href => `"${href}"`).join('\n ')}\n)`);
    })();
  2. smarteist revised this gist Feb 21, 2025. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions extractHrefsAsBashArray.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,9 @@
    function extractHrefsAsBashArray() {
    (function extractHrefsAsBashArray() {
    const domain = window.location.origin;
    const links = document.querySelectorAll('body main.container div.list table.table tbody tr td a');
    const hrefsArray = Array.from(links).map(link => {
    const href = link.getAttribute('href');
    return href ? (href.startsWith('http') ? href : domain + href) : '';
    }).filter(href => href); // Filter out empty strings
    }).filter(href => href);
    console.log(`hrefs=( ${hrefsArray.map(href => `"${href}"`).join(' ')} )`);
    }

    extractHrefsAsBashArray();
    })();
  3. smarteist created this gist Feb 21, 2025.
    11 changes: 11 additions & 0 deletions extractHrefsAsBashArray.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function extractHrefsAsBashArray() {
    const domain = window.location.origin;
    const links = document.querySelectorAll('body main.container div.list table.table tbody tr td a');
    const hrefsArray = Array.from(links).map(link => {
    const href = link.getAttribute('href');
    return href ? (href.startsWith('http') ? href : domain + href) : '';
    }).filter(href => href); // Filter out empty strings
    console.log(`hrefs=( ${hrefsArray.map(href => `"${href}"`).join(' ')} )`);
    }

    extractHrefsAsBashArray();