Skip to content

Commit

Permalink
Pull and replace styles from refined-github, fixes #799
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Dec 10, 2018
1 parent 8c0ea63 commit 226c191
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
23 changes: 15 additions & 8 deletions github-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
.TenYearNav-year:hover .TenYearNav-digits,
.gist-snippet-meta .gist-count-links > li > a:hover, .gist-quicksearch-results,
div#common-issues ul, .markdown-format img, .dropdown-menu,
.btn-primary .counter, .bg-white, .card, .pagination > span {
.btn-primary .counter, .bg-white, .card, .pagination > span,
.rgh-reactions-near-limit {
background: #181818 !important;
}
/* auto-generated rule for "background: #fafbfc" */
Expand Down Expand Up @@ -264,7 +265,8 @@
.suggester li[aria-selected=true],
.jump-to-suggestions-results-container .navigation-focus .jump-to-suggestions-path,
.jump-to-suggestions-results-container [aria-selected=true] .jump-to-suggestions-path,
.action-card-icon, .action-card-controls:after {
.action-card-icon, .action-card-controls:after,
.js-expandable-line:hover .diff-expander, .js-expandable-line:hover .blob-code {
background: /*[[base-color]]*/ #4f8cc9 !important;
}
/* auto-generated rule for "background-color: #0366d6" */
Expand Down Expand Up @@ -655,7 +657,8 @@
.form-checkbox .note, .hfields .form-group dt label, h2.account, p.explain,
.counter, .tabnav-tab, .tabnav-extra, .subnav-item, .headlines > li,
.sidebar-module ul h3, .sidebar-module ul ul li, h2 span.step, .content dt,
.content .full-image:hover .octicon, .full-image:hover .mini-icon {
.content .full-image:hover .octicon, .full-image:hover .mini-icon,
body > .footer li a {
color: #8e8e8e !important;
}
/* auto-generated rule for "color: #6a737d" */
Expand Down Expand Up @@ -711,7 +714,7 @@
.gist-snippet-meta .extra-info,
.gist-quicksearch-results .gist-quicksearch-result-header,
.gist-quicksearch-results .select-menu-item h4,
.gist-quicksearch-results .select-menu-item span {
.gist-quicksearch-results .select-menu-item span, .markdown-body del {
color: #8e8e8e !important;
}
/* auto-generated rule for "color: #959da5" */
Expand Down Expand Up @@ -897,7 +900,8 @@
.MarketingBody > p, .MarketingBody blockquote, .MarketingBody ol,
.MarketingBody ul, .DateNav .selected,
.gist-snippet-meta .gist-count-links > li > a,
.gist-revisions-list .gist-revision-meta {
.gist-revisions-list .gist-revision-meta,
.notifications-list .boxed-group-action button, .rgh-useless-comments-note {
color: #949494 !important;
}
/* auto-generated rule for "color: #24292e" */
Expand Down Expand Up @@ -1171,7 +1175,9 @@
.repository-merge-features .form-group.errored label,
.follow-list .follow-list-name a, .Bump-link--hover .Bump-link-symbol,
.page-gist-edit .btn-toggle-visibility .octicon-gist-secret, select,
.link-no-style, .link-no-style:hover {
.link-no-style, .link-no-style:hover,
.mergeability-details .js-details-container .status-meta,
:root .repohead h1 .commit-build-statuses .octicon {
color: inherit !important;
}
/* end auto-generated rules */
Expand Down Expand Up @@ -2922,7 +2928,6 @@
.tabs > a.selected, .member-username, .invited-banner p, kbd, .kbd,
.boxed-profile .profile-preview .vcard-fullname, .btn.btn-primary:hover,
.minibutton.btn-primary:hover, .integrations .site-footer a, .add-line-comment,
.blob-num-expandable .diff-expander:hover,
.email-format .email-hidden-toggle a:hover,
#gollum-editor-help-parent li a.selected,
#gollum-editor-help-list li a.selected, a.gollum-minibutton,
Expand Down Expand Up @@ -2963,7 +2968,9 @@
.select-menu-item[aria-selected="true"].selected, .btn-danger:hover,
.btn-danger:active, .btn-danger.selected, [open] > .btn-danger,
.discussion-item-icon,
a.octotree_toggle:not(.octotree_loading):hover > span:after {
a.octotree_toggle:not(.octotree_loading):hover > span:after,
.blob-num-expandable .diff-expander:hover,
.js-expandable-line:hover .diff-expander {
color: #dcdcdc !important;
}
pre, body, a.social-count, span.social-count, #languages a.bar, .lineoption p,
Expand Down
21 changes: 14 additions & 7 deletions tools/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ const urls = [
// {url: "https://github.com/login", opts: {headers: {"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Mobile Safari/537.36"}}},
];

// list of additional style URLs to pull
const additionalStyleUrls = [
"https://raw.githubusercontent.com/sindresorhus/refined-github/master/source/content.css",
"https://raw.githubusercontent.com/sindresorhus/refined-github/master/source/options.css",
];

// list of regexes matching selectors that should be ignored
const ignoreSelectors = [
/\.CodeMirror/,
Expand Down Expand Up @@ -221,11 +227,11 @@ async function writeOutput(generatedCss) {
async function extractStyleLinks(responses) {
const styleUrls = [];
for (const res of responses) {
extractStyleHrefs(await res.text()).forEach(href => {
for (const href of extractStyleHrefs(await res.text())) {
styleUrls.push(urlToolkit.buildAbsoluteURL(res.url, href));
});
}
}
return styleUrls;
return styleUrls.concat(additionalStyleUrls);
}

function extractStyleHrefs(html) {
Expand Down Expand Up @@ -257,8 +263,9 @@ function parseDeclarations(cssString) {
}

function parseRule(decls, rule) {
rule.declarations.forEach(decl => {
Object.keys(mappings).forEach(mapping => {
for (const decl of rule.declarations) {
for (const mapping of Object.keys(mappings)) {
if (!decl.value) continue;
if (!decls[mapping]) decls[mapping] = [];
const [prop, val] = mapping.split(": ");
decl.value = decl.value.replace(/!important/g, "").trim(); // remove !important
Expand All @@ -283,8 +290,8 @@ function parseRule(decls, rule) {
}
});
}
});
});
}
}
}

function buildOutput(decls) {
Expand Down

0 comments on commit 226c191

Please sign in to comment.