TRPL Bookmarks

Add bookmarks to the rust programming language website.

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         TRPL Bookmarks
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @description  Add bookmarks to the rust programming language website.
// @author       Cai
// @match        https://kaisery.github.io/trpl-zh-cn/*
// @grant        GM_addStyle
// ==/UserScript==

GM_addStyle(`
#menu-bar-sticky-container {
  backdrop-filter: blur(3px)!important;
  background: rgba(255,255,255,0.6)!important;
  border-bottom-width: 0!important;
}
.content main {
  margin-right: 0!important;
}
.cczz-out {
  position: fixed;
  top: 60px;
  z-index: 100;
  padding: 10px;
  border-radius: 5px;
  background: #ccc5;
  backdrop-filter: blur(2px);
}
.cczz-node {
  display: block;
}
.cczz-H2 {
  font-size: 16px;
  font-weight: bold;
}
.cczz-H3 {
  font-size: 14px;
  color: black!important;
}
.cczz-H4 {
  font-size: 12px;
  color: grey!important;
  text-indent: 24px;
}
`)

const $content = document.getElementById("content")
const $headers = $content.getElementsByClassName("header")
const $bookmark = document.createElement("DIV")
$bookmark.classList.add("cczz-out")
Array.from($headers).forEach($el => {
    const $node = document.createElement("A")
    $node.innerText = $el.innerText
    $node.href = $el.href
    $node.classList.add("cczz-node", "cczz-" + $el.children[0].tagName)
    $bookmark.appendChild($node)
})
$content.appendChild($bookmark)