Skip to content

Commit 86ec4b5

Browse files
committed
Add pypi_description_in_title.user.js
1 parent 1fdc4b6 commit 86ec4b5

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ To add a script:
5959
| [Another Open In Steam Button](#OISB) | [install][raw-OISB] | N/A | :heavy_check_mark: | MIT | 2022:11:25 | 2022:11:25 |
6060
| [Ubuntu Packages Description In Title](#UBDIT) | [install][raw-UBDIT] | N/A | :heavy_check_mark: | MIT | 2023:05:11 | 2023:05:11 |
6161
| [Quietly Reject StackExchange Cookies](#QRSC) | [install][raw-QRSC] | N/A | :heavy_check_mark: | MIT | 2023:05:14 | 2023:05:14 |
62+
| [PyPI Description In Title](#PDIT) | [install][raw-PDIT] | N/A | :heavy_check_mark: | MIT | 2023:05:31 | 2023:05:31 |
6263

6364
<!-- | [GitHub PR Obvious Fork Compare Button](#GPOFCB) | [install][raw-GPOFCB] | N/A | :heavy_check_mark: | MIT | 2021:03:16 | 2021:03:16 | -->
6465
<!-- | [Crates.io Common Meta Near Top](#CCMNT) | [install][raw-CCMNT] | N/A | :heavy_check_mark: | MIT | 2021:03:16 | 2021:04:05 | -->
@@ -366,6 +367,17 @@ Also hides a few other little things that just don't warrant another tiny script
366367

367368
[[Install]][raw-QRSC]
368369

370+
---
371+
372+
<a name="PDIT"></a>
373+
### PyPI Description In Title
374+
375+
Rewrite the page title for a PyPI package to include a brief summary, when available.
376+
377+
Also doesn't use that centered dot character as a separator.
378+
379+
[[Install]][raw-PDIT]
380+
369381
---
370382
<!--
371383
@@ -483,6 +495,7 @@ As explained on <https://stackoverflow.com/questions/7653483/github-relative-lin
483495
[raw-OISB]: /steam_app_from_webpage.user.js.user.js?raw=1
484496
[raw-UPDIT]: /ubuntu_packages_description_in_title.user.js?raw=1
485497
[raw-QRSC]: /quietly_reject_stackexchange_cookies.user.js?raw=1
498+
[raw-PDIT]: /pypi_description_in_title.user.js?raw=1
486499

487500
<!-- Legacy Workaround Scripts -->
488501
[raw-GLHW]: /legacy_browser_workarounds/github_line_hyperlink_workaround.user.js?raw=1

pypi_description_in_title.user.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ==UserScript==
2+
// @name PyPI Description In Title
3+
// @namespace https://github.com/StaticPH
4+
// @match https://pypi.org/project/*
5+
// @version 1.0
6+
// @createdAt 5/31/2023, 10:44:40 AM
7+
// @author StaticPH
8+
// @description Rewrite the page title for a PyPI package to include a brief summary, when available. Also doesn't use that centered dot character as a separator.
9+
// @license MIT
10+
// @updateURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/pypi_description_in_title.user.js
11+
// @downloadURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/pypi_description_in_title.user.js
12+
// @homepageURL https://github.com/StaticPH/UserScripts
13+
// @supportURL https://github.com/StaticPH/UserScripts/issues
14+
// @icon https://pypi.org/static/images/logo-small.2a411bc6.svg
15+
// @grant none
16+
// @run-at document-end
17+
// @noframes
18+
// ==/UserScript==
19+
20+
(function(){
21+
'use strict';
22+
23+
const pkgName = document.location.pathname.slice(9).split('/')[0];
24+
setTimeout(function wait(){
25+
const pkgDesc = document.querySelector('.package-description__summary');
26+
27+
if (pkgDesc){
28+
document.title = `${pkgName}${pkgDesc.textContent.trim()} | PyPI`;
29+
}
30+
else{
31+
setTimeout(wait, 100); // Continue trying every 100ms until success
32+
}
33+
});
34+
})();

0 commit comments

Comments
 (0)