1+ /**
2+ * revival of
3+ * @see https://web.archive.org/web/20131105145427/http://userscripts.org/scripts/review/86301
4+ */
5+ const styles = `
6+ .arrow.down {min-width:15px;min-height:14px;}
7+ .titText {font-size:smaller;color:darkSlateGray;font-weight:bold}
8+ .favicon {padding-right:17px;font-weight:bold;background-repeat:no-repeat;background-position:right center}
9+ `
10+ const sheet = document . createElement ( "style" )
11+ sheet . type = "text/css" ;
12+ sheet . innerText = styles ;
13+ document . head . appendChild ( sheet ) ;
14+
15+
16+ const sections = location . pathname . split ( / (? ! ^ ) \/ / ) ;
17+
18+
19+ // Select the node that will be observed for mutations
20+ const targetNode = document . querySelector ( '.ListingLayout-outerContainer' ) ;
21+
22+ // Options for the observer (which mutations to observe)
23+ const config = { attributes : true , childList : true , subtree : true } ;
24+
25+ const observer = new MutationObserver ( ( mutations , observer ) => {
26+ for ( const mut of mutations ) {
27+ if ( mut . type === 'childList' ) {
28+ run_it ( ) ;
29+ }
30+ }
31+ } ) ;
32+
33+ observer . observe ( targetNode , config ) ;
34+
35+
36+ function run_it ( ) {
37+ const loc = sections [ 0 ] ;
38+ if ( loc == '/user' ) [ ...document . querySelectorAll ( ".Comment a" ) ] . forEach ( element => {
39+ const href = element . getAttribute ( "href" ) ; ;
40+ if ( ! href ) return ;
41+ if ( element . title ) {
42+ if ( href != "/s" ) { // prevent revealing spoilers
43+ var tit = document . createElement ( "span" ) ;
44+ tit . textContent = "(" + element . title + ")" ;
45+ tit . className = "titText" ;
46+ element . parentNode . insertBefore ( tit , element ) ;
47+ }
48+ }
49+ if ( / \. (?: ( j p e ? | p n ) g | g i f | b m p ) / . test ( href ) ) {
50+ element . style . color = "blue" ;
51+ element . style . fontWeight = "bold" ;
52+ if ( href == element . textContent ) element . textContent = "{Image}" ;
53+ } else if ( href . indexOf ( "/" ) == 0 ) {
54+
55+ } else if ( / h t t p : \/ \/ (?: w w w \. ) ? r e d d i t \. c o m / . test ( href ) ) {
56+ if ( / u s e r \/ ( [ ^ \/ ] + ) $ / . test ( element . textContent ) ) element . textContent = "{User} " + RegExp . $1 ;
57+ else if ( / \/ r \/ ( [ ^ \/ ] + ) \/ ? (?: c o m m e n t s \/ [ ^ \/ ] + \/ ( .+ ) ) ? / . test ( href ) ) {
58+ if ( element . textContent == href ) element . textContent = "" ;
59+ var subreddit = RegExp . $1 ;
60+ if ( RegExp . $2 )
61+ element . innerHTML = element . textContent + " <small>{" + RegExp . $2 . replace ( / _ / g, " " ) . replace ( / \/ .* ?$ / , "" ) + " / " + subreddit + "}</small>" ;
62+ }
63+ element . className += " favicon" ;
64+ element . style . color = "crimson" ;
65+ element . style . backgroundImage = "url(\"http://www.reddit.com/static/favicon.ico\")" ;
66+ } else if ( / h t t p : \/ \/ (?: w w w \. ) ? y o u t u b e \. c o m / . test ( href ) ) {
67+ element . className += " favicon" ;
68+ element . style . color = "red" ;
69+ element . style . backgroundImage = "url(\"http://s.ytimg.com/yt/favicon.ico\")" ;
70+ if ( href == element . textContent ) element . textContent = "{Video}" ;
71+ } else if ( / h t t p : \/ \/ (?: w w w \. ) ? f a c e b o o k \. c o m / . test ( href ) ) {
72+ if ( href . match ( / [ & ? ] i d = ( \d + ) / ) )
73+ element . innerHTML = "Profile: {" + RegExp . $1 + "}" ;
74+ else if ( element . pathname . match ( / ^ \/ ( [ ^ ? & # ] + ) / ) )
75+ element . innerHTML = "Profile: " + RegExp . $1 ;
76+ element . className += " favicon" ;
77+ element . style . color = "darkBlue" ;
78+ element . style . backgroundImage = "url(http://slippyd.com/assets/70/logo.facebook.favicon.s16.png)" ;
79+ } else if ( / h t t p : \/ \/ (?: w w w \. ) ? e n \. w i k i p e d i a \. o r g \/ / . test ( href ) ) {
80+ if ( / \/ w i k i \/ ( [ ^ \/ ] + ) / . test ( element . pathname ) ) {
81+ if ( element . textContent == href ) element . innerHTML = "" ;
82+ element . innerHTML += " <small>{" + unescape ( RegExp . $1 ) . replace ( / _ / g, " " ) + "}</small>" ;
83+ }
84+ element . style . color = "black" ;
85+ element . style . backgroundImage = "url(\"http://en.wikipedia.org/favicon.ico\")" ;
86+ element . className += " favicon" ;
87+ } else {
88+ element . className += " favicon" ;
89+ element . style . color = "darkGreen" ;
90+ element . style . backgroundImage = "url(\"https://upload.wikimedia.org/wikipedia/commons/0/0f/External-link-ltr-icon_Dark.png\")" ;
91+ element . style . paddingRight = "11px" ;
92+ }
93+ } ) ;
94+ }
0 commit comments