Get All links from a website

Get all links from a website, change @match to the website which you want to get link from.

As of 13.02.2021. See ბოლო ვერსია.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Get All links from a website
// @name:zh-TW   获取网页中的全部链接
// @name:zh-HK   獲取網頁中的全部鏈接 
// @name:zh-CN   獲取網頁中的全部鏈接 
// @namespace    https://tdl3.com/
// @version      0.1.0
// @description  Get all links from a website, change @match to the website which you want to get link from.
// @description:zh-TW  获取网页中的全部链接,将 @match 改到你想获得链接的网站。
// @description:zh-HK  獲取網頁中的全部鏈接,將 @match 改到你想獲得鏈接的網站 。
// @description:zh-CN  獲取網頁中的全部鏈接,將 @match 改到你想獲得鏈接的網站 。
// @author       TDL3
// @match        https://heyeased.weebly.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

function make_table(links_and_names) {
    let table = "<table><thead><th>Names</th><th>Links</th></thead><tbody>";
    for (const [link, name] of Object.entries(links_and_names)) {
      table += `<tr><td> ${name} </td><td> ${link} </td></tr>`;
    }
    table += "</table>";
    window.open("").document.write(table);
  }

  function make_list(links) {
    let list = "";
    for (let link in links) {
      list += `<div>${links[link]}</div>`;
    }
    window.open("").document.write(list);
  }

  (function () {
    "use strict";
    let urls = document.querySelectorAll("a");
    let links_and_names = {};
    const name_regex = new RegExp("/png|jpg$/g");
    let res = false
    for (let i = 0; i < urls.length; i++) {
      let nametext = urls[i].textContent;
      let cleantext = nametext.replace(/\t|\s+/g, "").trim();
      let cleanlink = urls[i].href;
      // uncomment this line to get all links
      // let res = name_regex.test(cleanlink);
      // remove white spaces and tabs
      if (!res) {
          links_and_names[cleanlink] = cleantext;
      }
    }
    //make_list(Object.keys(links_and_names));
    make_table(links_and_names);
  })();