-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.js
122 lines (106 loc) · 2.18 KB
/
extension.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* Credits to 'deleerium' from HN.
* @link https://news.ycombinator.com/item?id=23199649
*/
const CSS = `body { background-color: #1F2430; }
#hnmain { background-color: #232834; }
a:link.storylink,
#hnmain > tbody > tr:first-child > td a,
.commtext, .commtext a:link, td, b {
color: #fafafa;
}
.comment > .commtext {
color: #fafafa;
}
td > .title {
color: #fafafa;
}
#hnmain > tbody > tr:first-child > td { background-color: #333a4a; }
a:link,
.sitebit, .subtext, .sitestr, .subtext a:link,
.rank, a.morelink,
.pagetop, .yclinks a, .yclinks > a:link,
.comhead a:link, .comhead,
.hnmore a:link, .reply a:link, {
color: #8c96ac;
}
td .pagetop {
color: #8c96ac;
}
td > a:link {
color: #8c96ac;
}
.title > a:link {
color: #8c96ac;
}
a > u {
color: #8c96ac;
}
.comment .reply u > a {
color: #8c96ac;
}
.title > a:visited {
color: #979cf4;
}
.commtext > p > a:link {
color: #fafafa;
}
.comment .commtext > a:link {
color: #fafafa;
}
.comment .commtext > a:visited {
color: #979cf4;
}
.commtext > p > a:visited {
color: #979cf4;
}
.votearrow {
overflow: visible;
position: relative;
}
.yclinks > a, .yclinks > a:link {
color: #8c96ac;
}
.yclinks > a:visited {
color: #979cf4;
}
.votearrow::before {
content: "";
width: 0;
height: 0;
left: 1px;
top: 3px;
display: block;
position: absolute;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 7px solid #bebfd1;
}
input[type=text],
textarea {
background-color: #333a4a;
color: #fafafa;
border: 1px solid #1F2430;
}
input[type=submit] {
background-color: #333a4a;
color: #fafafa;
border: 1px solid #1F2430;
}
b {
color: #fafafa;
}
}
`;
chrome.tabs.onUpdated.addListener(function ( tabId, info ) {
if ( info.status === "complete" ) {
chrome.tabs.get( tabId, function ( tab ) {
if (isHackerNews( tab.url ) ) {
chrome.tabs.insertCSS( tab.id, { code: CSS } );
}
});
}
});
function isHackerNews( url ) {
return new URL( url ).host === "news.ycombinator.com";
}