-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrs_description_in_title.user.js
36 lines (31 loc) · 1.41 KB
/
librs_description_in_title.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name Lib.rs Description In Title
// @namespace https://github.com/StaticPH
// @include https://lib.rs/crates/*
// @version 1.0
// @createdAt 4/28/2021
// @author StaticPH
// @description Replace the unhelpful part of the tab title on a crate's lib.rs page with the short description of the crate, if one is provided.
// @license MIT
// @updateURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/librs_description_in_title.user.js
// @downloadURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/librs_description_in_title.user.js
// @homepageURL https://github.com/StaticPH/UserScripts
// @supportURL https://github.com/StaticPH/UserScripts/issues
// @icon https://lib.rs/favicon.png
// @grant none
// @run-at document-idle
// ==/UserScript==
(function(){
'use strict';
setTimeout(function wait(){
const crateName = document.querySelector('div.inner-col > h2 > span[property="name"]');
const crateDesc = document.querySelector('div.inner-col > p.desc');
//TODO: Modify script to also indicate which crate subpage is currently loaded (if it isnt the readme subpage)
if (crateName && crateDesc){
document.title=`${crateName.textContent.trim()} — ${crateDesc.textContent.trim()}`;
}
else{
setTimeout(wait, 100); // Continue trying every 100ms until success
}
});
})();