├── .editorconfig ├── .eslintrc ├── .gitattributes ├── .github └── CONTRIBUTING.md ├── .gitignore ├── .mailmap ├── .stylelintrc ├── .travis.yml ├── AUTHORS ├── README.md ├── defaults.json ├── github-compact-feed.user.css ├── images ├── customization.png ├── dashboard-after.png └── dashboard-before.png ├── package.json └── tools ├── authors ├── bump-version.js ├── fix-perfectionist.js ├── update-usercss.js ├── usercss-template.css └── utils.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | trim_trailing_whitespace = true 8 | end_of_line = lf 9 | charset = utf-8 10 | insert_final_newline = true 11 | 12 | [*.css] 13 | block_comment_start = /* 14 | block_comment = * 15 | block_comment_end = */ 16 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | root: true 2 | extends: eslint-config-silverwind 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | 1. [Getting Involved](#getting-involved) 4 | 2. [How To Report style issues](#how-to-report-style-issues) 5 | 3. [Core Style Guide](#style-guide) 6 | 4. [Getting Started](#getting-started) 7 | 8 | ## Getting Involved 9 | 10 | There are a number of ways to get involved with the development of this theme. Even if you've never contributed to an Open Source project before, we're always looking for help identifying missing styles or other issues. 11 | 12 | ## How to Report Style issues 13 | 14 | ### I don't know CSS 15 | 16 | If you don't know CSS very well and have found a missing style, please include as much as possible of following information when opening an issue: 17 | 18 | * Screenshot of the problem; include the element(s) in the console if at all possible 19 | * To select an element, target it with your mouse then right-click and choose "Inspect Element" 20 | * Please include both the HTML view and the element with the problem in the screenshot (see [issue #119](https://github.com/StylishThemes/GitHub-Dark/issues/119) for an example) 21 | * A URL to the page (if public). 22 | 23 | ### I rock at CSS & GitHub! 24 | 25 | * Follow the style guide below 26 | * Make any needed changes, then send us a pull request 27 | * Please include a url to the page (if public) 28 | 29 | ## Style Guide 30 | 31 | * Use the provided `.editorconfig` file with your code editor. Don't know what that is? Then check out http://editorconfig.org/. 32 | * Limit to the [K&R Style](https://en.wikipedia.org/wiki/Indentation_style#K.26R), and **2 SPACE INDENTATION** (no tabs, and not more, and not less than 2 spaces). 33 | 34 | * K&R Example: 35 | ```css 36 | element[attr='value'] { 37 | ··property: value; 38 | } 39 | ``` 40 | 41 | * **Not Allman** 42 | ```css 43 | element[property='value'] 44 | { 45 | ··property: value; 46 | } 47 | ``` 48 | 49 | * Strict space between the `selector` and the `{`: 50 | ```css 51 | /* good */ 52 | element[attr='value'] { } 53 | 54 | /* bad */ 55 | element[attr='value']{ } 56 | ``` 57 | 58 | * 2 Space indentation 59 | ```css 60 | /* good */ 61 | ··property: value; 62 | 63 | /* bad */ 64 | ····property: value; 65 | ----property: value; 66 | ·property: value; 67 | ``` 68 | 69 | * Try to wrap lines at around 80 characters. 70 | * Try to limit the style size: 71 | * Don't add any image URI's to the css; instead add the image into the `/images` directory; then point to using the following url: `http://stylishthemes.github.io/GitHub-Compact-Feed/images/`{my-image.png}. 72 | * If possible, reduce any added selectors. Remember that Stylus requires an `!important` flag to override default styling, so a selector starting from the body isn't always necessary. 73 | * Don't add any inline comments. If you want to make a comment, add it as a note in the commit. 74 | * If your css definition already exists within the style, do not add it again! Add your selector to the existing definition. 75 | * Insert any new css selectors in the available slot immediately before the style definition, or on a new line as needed. 76 | * If you want to add a new userstyle or usercss variable, please open an issue and discuss it with us first. 77 | 78 | ## Getting Started 79 | 80 | * [Download](https://github.com/StylishThemes/GitHub-Compact-Feed/archive/master.zip), [fork](https://github.com/StylishThemes/GitHub-Compact-Feed/fork) or clone this repository. 81 | * Use [node.js](http://nodejs.org/) to run `npm install`. 82 | * Make any changes to the `github-compact-feed.user.css` file and save. 83 | 84 | ### Build & test 85 | 86 | * Create & change into a new branch of your local GitHub-Compact-Feed repository. 87 | * Open the style in the Stylus editor, and make sure to have "live preview" checked for testing. 88 | * Once you are satisfied with the changes, select all the css (Ctrl + a), copy (Ctrl + c) then paste (Ctrl + v) it into your editor. 89 | * Run `npm test` to test the css changes. 90 | * Now you can add and commit the changes of the `github-compact-feed.user.css` file to your fork's branch. 91 | * If you haven't already contributed, then run `npm run authors` to add your name to our list of contributors :smile: 92 | * Push the changes to your branch, then submit a pull request. 93 | * And thanks again for contributing! 94 | 95 | ### Development Scripts 96 | 97 | * `npm run authors`: Runs a batch file to rebuild the `AUTHORS` file. Update the `.mailmap` file for any duplicate entries. 98 | * `npm run clean`: Runs the perfectionist script & cleans up after it. 99 | * `npm run eslint`: Lint the JavaScript code in the `tools` directory. 100 | * `npm run lint`: Run eslint & stylelint scripts. 101 | * `npm run major`: Creates a semantic major release. 102 | * `npm run minor`: Creates a semantic minor release. 103 | * `npm run patch`: Creates a semantic patch release. 104 | * `npm run perfectionist`: Runs perfectionist only. CSS is not cleaned! 105 | * `npm run stylelint`: Run stylelint on the css file. 106 | * `npm run test`: Same as `npm run lint`. 107 | * `npm run update`: Update development dependencies. 108 | * `npm run usercss`: Update usercss variables using usercss template; variable data obtained from `defaults.json`. 109 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # lockfiles 2 | package-lock.json 3 | yarn.lock 4 | 5 | # temp stuff 6 | tmp/ 7 | *.tmp 8 | *.bak 9 | 10 | # logs 11 | *.stackdump 12 | *.log 13 | 14 | # Build 15 | node_modules/ 16 | build.json 17 | *.build.css 18 | 19 | # Windows crap 20 | Thumbs.db 21 | Desktop.ini 22 | 23 | # Mac crap 24 | .DS_Store 25 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Rob Garrison Mottie 2 | Rob Garrison Rob G 3 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | # https://github.com/stylelint/stylelint/blob/master/docs/user-guide/rules.md 2 | # https://github.com/stylelint/stylelint-config-standard/blob/master/index.js 3 | 4 | extends: stylelint-config-standard 5 | 6 | rules: 7 | at-rule-empty-line-before: null 8 | block-no-empty: null 9 | block-opening-brace-space-before: null 10 | color-hex-case: null 11 | color-named: null 12 | comment-empty-line-before: null 13 | comment-no-empty: null 14 | comment-whitespace-inside: null 15 | declaration-bang-space-before: null 16 | declaration-block-no-duplicate-properties: null 17 | declaration-block-single-line-max-declarations: null 18 | declaration-colon-newline-after: null 19 | font-family-name-quotes: always-where-recommended 20 | font-family-no-duplicate-names: true 21 | function-url-quotes: always 22 | indentation: null 23 | max-empty-lines: 0 24 | no-descending-specificity: null 25 | no-duplicate-selectors: null 26 | number-leading-zero: never 27 | number-max-precision: 3 28 | number-no-trailing-zeros: true 29 | rule-empty-line-before: null 30 | selector-combinator-space-after: null 31 | selector-combinator-space-before: null 32 | selector-list-comma-newline-after: null 33 | selector-pseudo-element-colon-notation: single 34 | selector-type-no-unknown: null 35 | string-quotes: double 36 | value-list-comma-newline-after: null 37 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - node 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Authors ordered by first contribution. 2 | 3 | Rob Garrison 4 | 5 | # Generated by tools/authors.sh 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Compact Feed [![tag](https://img.shields.io/github/tag/StylishThemes/GitHub-Compact-Feed.svg)](https://github.com/StylishThemes/GitHub-Compact-Feed/tags) 2 | 3 | A userstyle that compacts and hides details in the news feed. 4 | 5 | Almost all details are hidden in the feed, except: 6 | 7 | * New repos and repos made public. 8 | * Pull request details. 9 | * Wiki changes maintain a link to the diff. 10 | 11 | ## Preview 12 | 13 | | Before | After | 14 | |:------:|:-----:| 15 | | ![](./images/dashboard-before.png) | ![](./images/dashboard-after.png) | 16 | 17 | ## Customization 18 | 19 | In version 1.1.0+, visibility of feed may be dynamically set within the [Stylus](https://add0n.com/stylus.html)' [configuration popup](https://github.com/openstyles/stylus/wiki/Popup). 20 | 21 | ![](./images/customization.png) 22 | 23 | All feed entries are visible by default. And this customization is *not available* through installation from userstyles.org because you would need to go to that site each time you want to change the visibility of an item. 24 | 25 | ## Installation 26 | 27 | A userstyle extension is required, common ones include: 28 | 29 | 🎨 Stylus for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/styl-us/), [Chrome](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne) or [Opera](https://addons.opera.com/en-gb/extensions/details/stylus/).
30 | 🎨 xStyle for [Firefox](https://addons.mozilla.org/firefox/addon/xstyle/) or [Chrome](https://chrome.google.com/webstore/detail/xstyle/hncgkmhphmncjohllpoleelnibpmccpj). 31 | 32 | Then: 33 | 34 | 📦 [Install the usercss](https://github.com/StylishThemes/GitHub-Compact-Feed/raw/master/github-compact-feed.user.css) with Stylus or xStyle. Supports automatic updates. 35 | 36 | ## Contributions 37 | 38 | If you would like to contribute to this repository, please... 39 | 40 | 1. 👓 Read the [contribution guidelines](CONTRIBUTING.md). 41 | 2. ![repo-forked](https://user-images.githubusercontent.com/136959/42383736-c4cb0db8-80fd-11e8-91ca-12bae108bccc.png) [fork](https://github.com/StylishThemes/GitHub-Compact-Feed/fork) or ![cloud-download](https://user-images.githubusercontent.com/136959/42401932-9ee9cae0-813d-11e8-8691-16e29a85d3b9.png) 42 | [Download](https://github.com/StylishThemes/GitHub-Compact-Feed/archive/master.zip), 43 | 3. 👌 Create a pull request! 44 | 45 | Thanks to all that have [contributed](AUTHORS) so far! 46 | -------------------------------------------------------------------------------- /defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "preprocessor": "stylus", 3 | "variables": { 4 | "Hide All Comments": { 5 | "type": "checkbox", 6 | "label": "hide_comments", 7 | "value": "0" 8 | }, 9 | "Hide Branch Edits": { 10 | "type": "checkbox", 11 | "label": "hide_branches", 12 | "value": "0" 13 | }, 14 | "Hide Closing": { 15 | "type": "checkbox", 16 | "label": "hide_closed", 17 | "value": "0" 18 | }, 19 | "Hide Follows": { 20 | "type": "checkbox", 21 | "label": "hide_follows", 22 | "value": "0" 23 | }, 24 | "Hide Forks": { 25 | "type": "checkbox", 26 | "label": "hide_forks", 27 | "value": "0" 28 | }, 29 | "Hide New Repos": { 30 | "type": "checkbox", 31 | "label": "hide_new", 32 | "value": "0" 33 | }, 34 | "Hide Open/Reopen": { 35 | "type": "checkbox", 36 | "label": "hide_open", 37 | "value": "0" 38 | }, 39 | "Hide Stars": { 40 | "type": "checkbox", 41 | "label": "hide_stars", 42 | "value": "0" 43 | }, 44 | "Hide Tags": { 45 | "type": "checkbox", 46 | "label": "hide_tags", 47 | "value": "0" 48 | }, 49 | "Hide Pushes": { 50 | "type": "checkbox", 51 | "label": "hide_pushes", 52 | "value": "0" 53 | }, 54 | "Hide Wiki Events": { 55 | "type": "checkbox", 56 | "label": "hide_wiki", 57 | "value": "0" 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /github-compact-feed.user.css: -------------------------------------------------------------------------------- 1 | /* ==UserStyle== 2 | @name GitHub Compact Feed 3 | @version 1.2.3 4 | @description Compact and hide details in the news feed 5 | @namespace StylishThemes 6 | @author StylishThemes 7 | @homepageURL https://github.com/StylishThemes/GitHub-Compact-Feed 8 | @supportURL https://github.com/StylishThemes/GitHub-Compact-Feed/issues 9 | @updateURL https://raw.githubusercontent.com/StylishThemes/GitHub-Compact-Feed/master/github-compact-feed.user.css 10 | @license CC-BY-SA-4.0 11 | @advanced checkbox hide_comments "Hide All Comments" 0 12 | @advanced checkbox hide_branches "Hide Branch Edits" 0 13 | @advanced checkbox hide_closed "Hide Closing" 0 14 | @advanced checkbox hide_follows "Hide Follows" 0 15 | @advanced checkbox hide_forks "Hide Forks" 0 16 | @advanced checkbox hide_new "Hide New Repos" 0 17 | @advanced checkbox hide_open "Hide Open/Reopen" 0 18 | @advanced checkbox hide_stars "Hide Stars" 0 19 | @advanced checkbox hide_tags "Hide Tags" 0 20 | @advanced checkbox hide_pushes "Hide Pushes" 0 21 | @advanced checkbox hide_wiki "Hide Wiki Events" 0 22 | @preprocessor stylus 23 | ==/UserStyle== */ 24 | @-moz-document regexp("^https?:\\/\\/github\\.com(\\/)?$"), regexp("^https?:\\/\\/github\\.com\\/(orgs\\/.*\\/)?dashboard(\\/)?$") { 25 | if hide_comments { 26 | .news .issues_comment, .news .commit_comment { 27 | display: none !important; 28 | } 29 | } 30 | if hide_branches { 31 | .news .git-branch { 32 | display: none !important; 33 | } 34 | } 35 | if hide_closed { 36 | .news .issues_closed { 37 | display: none !important; 38 | } 39 | } 40 | if hide_follows { 41 | .news .follow { 42 | display: none !important; 43 | } 44 | } 45 | if hide_forks { 46 | .news .fork { 47 | display: none !important; 48 | } 49 | } 50 | if hide_stars { 51 | .news .watch_started { 52 | display: none !important; 53 | } 54 | } 55 | if hide_new { 56 | .news .repo, .news .create, .news .public { 57 | display: none !important; 58 | } 59 | } 60 | if hide_open { 61 | .news .issues_opened, .news .issues_reopened { 62 | display: none !important; 63 | } 64 | } 65 | if hide_pushes { 66 | .news .push { 67 | display: none !important; 68 | } 69 | } 70 | if hide_tags { 71 | .news .tag { 72 | display: none !important; 73 | } 74 | } 75 | if hide_wiki { 76 | .news .gollum { 77 | display: none !important; 78 | } 79 | } 80 | /* Hide expand button */ 81 | .news div > .Details .js-details-target, 82 | /* Hide star repo details */ 83 | .news .watch_started .Box, 84 | /* Hide text with 2+ stars */ 85 | .news .watch_started .text-gray, 86 | /* .fork .border not using .Box yet */ 87 | .news .fork .border, .news .fork .Box, 88 | .news .tag .Box, .news .git-branch .Box, 89 | /* Hide created repo update date */ 90 | .news .repo .Box .f6, 91 | .news .public .border .f6, 92 | /* .public .border not using .Box yet */ 93 | .news .public .Box .f6, 94 | .news .issues_comment .message, .news .commit_comment .message, 95 | /* Multiple comments */ 96 | .news .issues_comment .Details .mt-2, 97 | /* Multiple comments */ 98 | .news .commit_comment .Details .mt-2, 99 | /* Hide issue text */ 100 | .news .issues_opened .Box div.lh-condensed, 101 | .news .issues_closed .Box div.lh-condensed, .news .issues_closed .Box .f6, 102 | .news .issues_closed .border .f6, .news .issues_reopened .Box div.lh-condensed, 103 | .news .issues_reopened .Box .f6, 104 | /* Hide PR diff stats */ 105 | .news .border .diffstat, .news .follow .Box { 106 | display: none !important; 107 | } 108 | .news > div .Details:not(.Details--on) div.Details-content--hidden, 109 | /* Show multiple star repo names */ 110 | .news .fork .Details .Box, 111 | .news .watch_started .Details .Box, 112 | .news .create .Details .d-flex .Box, 113 | /* Show star on created/public repos */ 114 | .news .create .starring-container button[data-hydro-click] { 115 | display: block !important; 116 | } 117 | .news .watch_started .Details .d-flex .Box, .news .issues_opened .Box, 118 | .news .issues_closed .Box, .news .issues_reopened .Box { 119 | border: 0 !important; 120 | background: transparent !important; 121 | padding: 0 !important; 122 | margin-bottom: 0 !important; 123 | } 124 | /* Remove extra padding after comment is hidden */ 125 | .news .p-3, 126 | /* Padding after PR diff-stat hidden */ 127 | .news .border.p-3, 128 | .news .repo .Box.p-3, .news .public .border.p-3, .news .public .Box.p-3 { 129 | padding-bottom: 5px !important; 130 | padding-top: 5px !important; 131 | } 132 | .news p { 133 | margin-bottom: 0 !important; 134 | } 135 | /* Limit issue title width */ 136 | .news .issues_opened .Box a, .news .issues_closed .Box a { 137 | display: inline-block !important; 138 | white-space: nowrap !important; 139 | max-width: 500px !important; 140 | overflow: hidden !important; 141 | text-overflow: ellipsis !important; 142 | } 143 | /* Edited wiki, move "View the diff" inline */ 144 | .news .gollum .text-gray .mt-2 { 145 | display: inline-block !important; 146 | } 147 | /* Move "# more commits" to bottom right */ 148 | .news .push .link-gray { 149 | float: right !important; 150 | top: -2em !important; 151 | position: relative !important; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /images/customization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StylishThemes/GitHub-Compact-Feed/c516ecd5b8508d1f9c2efd14a006e81d92562d4e/images/customization.png -------------------------------------------------------------------------------- /images/dashboard-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StylishThemes/GitHub-Compact-Feed/c516ecd5b8508d1f9c2efd14a006e81d92562d4e/images/dashboard-after.png -------------------------------------------------------------------------------- /images/dashboard-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StylishThemes/GitHub-Compact-Feed/c516ecd5b8508d1f9c2efd14a006e81d92562d4e/images/dashboard-before.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-compact-feed", 3 | "title": "GitHub Compact Feed", 4 | "version": "1.2.3", 5 | "description": "Compact and hide details in the news feed", 6 | "license": "CC-BY-SA-4.0", 7 | "repository": "https://github.com/StylishThemes/GitHub-Compact-Feed", 8 | "homepage": "https://github.com/StylishThemes/GitHub-Compact-Feed", 9 | "main": "github-compact-feed.user.css", 10 | "engines": { 11 | "node": ">=10" 12 | }, 13 | "devDependencies": { 14 | "eslint": "^5.16.0", 15 | "eslint-config-silverwind": "^3.0.2", 16 | "perfectionist": "^2.4.0", 17 | "semver": "^6.1.1", 18 | "stylelint": "^10.0.1", 19 | "stylelint-config-standard": "^18.3.0", 20 | "updates": "^8.0.3" 21 | }, 22 | "scripts": { 23 | "authors": "bash tools/authors", 24 | "clean": "npm run perfectionist && node tools/fix-perfectionist.js", 25 | "eslint": "eslint --quiet --color tools/*.js", 26 | "lint": "npm run eslint && npm run stylelint", 27 | "major": "node tools/bump-version.js major && git add . && npm version -f major", 28 | "minor": "node tools/bump-version.js minor && git add . && npm version -f minor", 29 | "patch": "node tools/bump-version.js patch && git add . && npm version -f patch", 30 | "perfectionist": "perfectionist github-compact-feed.user.css github-compact-feed.user.css --indentSize 2 --maxAtRuleLength 250", 31 | "stylelint": "stylelint --color -- github-compact-feed.user.css", 32 | "test": "npm run eslint && npm run stylelint", 33 | "update": "updates -cu && npm install", 34 | "usercss": "node tools/update-usercss.js" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tools/authors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # generate AUTHORS, modify .mailmap in case of duplicates 4 | git log --reverse --format='%aN <%aE>' | perl -we ' 5 | BEGIN { 6 | %seen = (), @authors = (); 7 | } 8 | while (<>) { 9 | next if $seen{$_}; 10 | $seen{$_} = push @authors, $_; 11 | } 12 | END { 13 | print "# Authors ordered by first contribution.\n"; 14 | print "\n", @authors, "\n"; 15 | print "# Generated by tools/authors.sh\n"; 16 | } 17 | ' > "${BASH_SOURCE%/*}/../AUTHORS" 18 | -------------------------------------------------------------------------------- /tools/bump-version.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const fs = require("fs").promises; 5 | const path = require("path"); 6 | const semver = require("semver"); 7 | 8 | const pkg = require("../package.json"); 9 | 10 | const file = path.join(__dirname, "..", pkg.main); 11 | 12 | (async () => { 13 | // level = patch, minor or major 14 | const level = process.argv.pop(); 15 | const newVersion = semver.inc(pkg.version, level); 16 | 17 | fs.readFile(file, "utf8") 18 | .then(css => css.replace(pkg.version, newVersion)) 19 | .then((css) => { 20 | if (css.indexOf(newVersion) < 0) { 21 | throw new Error("*** VERSION MISMATCH!! ***"); 22 | } 23 | return css; 24 | }) 25 | .then(css => fs.writeFile(file, css)) 26 | .then(() => console.log("\x1b[32m%s\x1b[0m", `${pkg.title} usercss updated`)) 27 | .catch(exit); 28 | })(); 29 | 30 | function exit(err) { 31 | if (err) { 32 | console.error(err); 33 | } 34 | process.exit(err ? 1 : 0); 35 | } 36 | -------------------------------------------------------------------------------- /tools/fix-perfectionist.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const fs = require("fs").promises; 5 | const path = require("path"); 6 | const pkg = require("../package.json"); 7 | 8 | const fileName = path.join(__dirname, "..", pkg.main); 9 | 10 | function cleanup(css) { 11 | return css 12 | // Perfectionist adds comments to the end of the previous line... 13 | // }/* comment */ => }\n\n /* comment */ 14 | .replace(/}\/\*(([\s\S])+?)\*\/\s*/g, "}\n\n /*$1*/\n ") 15 | .replace(/,\s\/\*/g, ",\n /*") 16 | // Remove extra carriage returns between definitions 17 | .replace(/\n+/g, "\n"); 18 | } 19 | 20 | async function postPerfectionist() { 21 | const css = await fs.readFile(fileName, "utf8"); 22 | await fs.writeFile(fileName, cleanup(css)); 23 | console.log("\x1b[32m%s\x1b[0m", `${pkg.title} usercss cleanup completed`); 24 | } 25 | 26 | postPerfectionist(); 27 | -------------------------------------------------------------------------------- /tools/update-usercss.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const fs = require("fs").promises; 5 | const path = require("path"); 6 | 7 | const {replaceHolders, maxSize, pad} = require("./utils"); 8 | const pkg = require("../package.json"); 9 | 10 | const files = { 11 | defaults: path.join(__dirname, "..", "defaults.json"), 12 | usercss: path.join(__dirname, "..", pkg.main), 13 | template: path.join(__dirname, "usercss-template.css"), 14 | }; 15 | 16 | const defaults = require(files.defaults); 17 | 18 | function addVars(template, usercss) { 19 | const vars = defaults.variables; 20 | const keys = Object.keys(vars); 21 | const typeLen = maxSize(keys.map(key => vars[key].type)); 22 | const labelLen = maxSize(keys.map(key => vars[key].label)); 23 | const keyLen = maxSize(keys.map(key => key)); 24 | const variables = keys.map((key) => { 25 | const e = vars[key]; 26 | const v = e.type !== "dropdown" ? 27 | e.value : 28 | `{\n ${Object.keys(e.value) 29 | .map(o => `${o} "${o}" << 50 | fs 51 | .readFile(files.usercss, "utf8") 52 | .then(usercss => addVars(template, usercss)) 53 | ) 54 | .then(css => fs.writeFile(files.usercss, css)) 55 | .then(() => console.log("\x1b[32m%s\x1b[0m", `${pkg.title} usercss update complete`)) 56 | .catch(exit); 57 | -------------------------------------------------------------------------------- /tools/usercss-template.css: -------------------------------------------------------------------------------- 1 | /* ==UserStyle== 2 | @name {{title}} 3 | @version {{version}} 4 | @description {{description}} 5 | @namespace StylishThemes 6 | @author StylishThemes 7 | @homepageURL https://github.com/{{repository}} 8 | @supportURL https://github.com/{{repository}}/issues 9 | @updateURL https://raw.githubusercontent.com/{{repository}}/master/{{main}} 10 | @license CC-BY-SA-4.0 11 | {{variables}} 12 | @preprocessor {{preprocessor}} 13 | ==/UserStyle== */ 14 | -------------------------------------------------------------------------------- /tools/utils.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | // Replace placeholders in template 5 | function replaceHolders(pkg, css) { 6 | const placeholders = css.match(/\{\{\S+?\}\}/g); 7 | const domain = "https://github.com/"; 8 | if (placeholders) { 9 | new Set(placeholders).forEach((name) => { 10 | let val = (pkg[name.replace(/[{}]/g, "")] || name); 11 | if (val.indexOf(domain) > -1) { 12 | val = val.substring(domain.length, val.length); 13 | } 14 | css = css.replace(new RegExp(escapeRegex(name), "gi"), val); 15 | }); 16 | } 17 | return css; 18 | } 19 | 20 | function escapeRegex(str) { 21 | return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); 22 | } 23 | 24 | function maxSize(array) { 25 | return array.reduce((acc, item) => Math.max(acc, item.length), 0); 26 | } 27 | 28 | function pad(len, str) { 29 | return (str || "").padEnd(len); 30 | } 31 | 32 | module.exports = { 33 | replaceHolders, 34 | escapeRegex, 35 | maxSize, 36 | pad, 37 | }; 38 | --------------------------------------------------------------------------------