-
Notifications
You must be signed in to change notification settings - Fork 1
/
msys2_package_description_in_title.user.js
36 lines (31 loc) · 1.39 KB
/
msys2_package_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 MSYS Packages Description In Title
// @namespace https://github.com/StaticPH
// @include http*://packages.msys2.org/package/*
// @version 1.0
// @createdAt 4/28/2021
// @author StaticPH
// @description Include the package description on the tab title for a package's page on packages.msys2.org/packages.
// @license MIT
// @updateURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/msys2_package_description_in_title.user.js
// @downloadURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/msys2_package_description_in_title.user.js
// @homepageURL https://github.com/StaticPH/UserScripts
// @supportURL https://github.com/StaticPH/UserScripts/issues
// @icon https://packages.msys2.org/static/images/logo.svg
// @grant none
// @run-at document-idle
// ==/UserScript==
(function(){
'use strict';
setTimeout(function wait(){
const pkgName = document.querySelector('h4.card-title');
const pkgDesc = document.querySelector('h6.card-subtitle');
//TODO: Modify script to also indicate which pkg subpage is currently loaded (if it isnt the readme subpage)
if (pkgName && pkgDesc){
document.title=`${pkgName.textContent.trim()} — ${pkgDesc.textContent.trim()}`;
}
else{
setTimeout(wait, 100); // Continue trying every 100ms until success
}
});
})();