forked from samliew/SO-mod-userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExpandShortLinks.user.js
50 lines (41 loc) · 1.24 KB
/
ExpandShortLinks.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ==UserScript==
// @name Expand Short Links
// @description Appends more characters to short link texts in posts and comments so they can be easily seen and clicked on
// @homepage https://github.com/samliew/SO-mod-userscripts
// @author @samliew
// @version 1.2.3
//
// @include https://*stackoverflow.com/*
// @include https://*serverfault.com/*
// @include https://*superuser.com/*
// @include https://*askubuntu.com/*
// @include https://*mathoverflow.net/*
// @include https://*.stackexchange.com/*
// ==/UserScript==
(function() {
'use strict';
function expandShortLinks() {
$('.post-text, .comment-copy').find('a').not('.post-tag').not('.shortlink').filter((i,el) => el.innerText.length > 0 && el.innerText.length <= 2 && el.children.length == 0).addClass('shortlink');
}
function appendStyles() {
const styles = `
<style>
a.shortlink {
font-weight: bold;
color: red !important;
}
a.shortlink:after {
content: '_link';
color: green;
font-style: italic;
font-weight: normal;
}
</style>
`;
$('body').append(styles);
}
// On page load
appendStyles();
expandShortLinks();
$(document).ajaxComplete(expandShortLinks);
})();