Skip to content

Instantly share code, notes, and snippets.

@natzir
Last active February 19, 2024 08:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natzir/fb7fdaef6655cef3da5424c7ef976eea to your computer and use it in GitHub Desktop.
Save natzir/fb7fdaef6655cef3da5424c7ef976eea to your computer and use it in GitHub Desktop.
Internal Link Checker Bookmarklet
@natzir
Copy link
Author

natzir commented Sep 22, 2023

This JavaScript code is a bookmarklet designed to assess and visually represent the status of internal links on a webpage. The script checks each internal link's status and applies a background color depending on the state of the link. Here's what the script does in detail:

  1. Scans All Links: The script scans all links on the page and filters them to include only internal links, i.e., links that point to the same domain as the current page.
  2. Identifies Link Types & Errors:
  • Highlights links with query strings in yellow.
  • Marks 'nofollow', 'sponsored', and 'ugc' links in orange.
  • Identifies links blocked by robots.txt and highlights them in red.
  • Highlights 3XX redirected links in olive.
  • Marks 4XX client errors in silver.
  • Represents 5XX server errors in aqua.
  1. Displays a Legend: Creates and displays a legend on the page to explain the color coding. It shows a count of each type of link found on the page, serving as a quick report.

Usage:
To use this script, you can create a new bookmark and paste the provided JavaScript code as the bookmark's URL. When you click on this bookmark while on any webpage, it will execute the script and visually modify the internal links according to their statuses as described.

Note:
Ensure that the web page is fully loaded before executing the script, as it may not properly identify and mark all links if the page is still loading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment