crates.io -> lib.rs

Replace all links to crates.io with ones to lib.rs, as the latter is much faster because it doesn't use tons of JavaScript

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 or Violentmonkey 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         crates.io -> lib.rs
// @version      0.1.5
// @license      GPL-3.0-only; http://www.gnu.org/licenses/gpl-3.0.txt
// @homepageURL  https://github.com/Logarithmus/crates-io-to-lib-rs
// @copyright    2020, Logarithmus (https://github.com/Logarithmus)
// @description  Replace all links to crates.io with ones to lib.rs, as the latter is much faster because it doesn't use tons of JavaScript
// @author       Logarithmus
// @match        *://*/*
// @namespace https://greasyfork.org/users/475664
// ==/UserScript==

(function() {
    if (window.location.hostname === "crates.io") {
        return
    }

    for (let a of document.getElementsByTagName("a")) {
        // Only modify relevant <a> tags to avoid breaking sites
        if (a.hostname === "crates.io"
         && a.pathname.indexOf("/crates/") === 0) {
            a.hostname = "lib.rs"
        }
    }
})();