├── .gitignore ├── README.md ├── manifest-v2 ├── LICENSE.txt ├── css │ └── comment-collapser.css ├── image │ ├── collapse-dark.png │ ├── collapse.png │ ├── colours │ │ ├── army.png │ │ ├── blue.png │ │ ├── brown.png │ │ ├── dark_green.png │ │ ├── green.png │ │ ├── lilac.png │ │ ├── navy.png │ │ ├── orange.png │ │ ├── pink.png │ │ └── red.png │ ├── expand-dark.png │ ├── expand.png │ ├── icon128.png │ ├── icon48.png │ ├── promo1.png │ ├── screenshot1.png │ └── screenshot2.png ├── js │ ├── comment-collapser.js │ └── options.js ├── manifest.json └── views │ └── options.html └── manifest-v3 ├── LICENSE.txt ├── Makefile ├── css └── comment-collapser.css ├── image ├── collapse-dark.png ├── collapse.png ├── colours │ ├── army.png │ ├── blue.png │ ├── brown.png │ ├── dark_green.png │ ├── green.png │ ├── lilac.png │ ├── navy.png │ ├── orange.png │ ├── pink.png │ └── red.png ├── expand-dark.png ├── expand.png ├── icon128.png ├── icon48.png ├── promo1.png ├── screenshot1.png └── screenshot2.png ├── js ├── comment-collapser.js └── options.js ├── manifest.json └── views └── options.html /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.zip 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Reddit Comment Collapser 2 | 3 | [Chrome extension](https://chrome.google.com/webstore/detail/reddit-comment-collapser/njmimaecgocggclbecipdimilidimlpl) 4 | 5 | [Firefox addon](https://addons.mozilla.org/en-GB/firefox/addon/reddit_comment_collapser/) 6 | 7 | --- 8 | 9 | Reddit Comment Collapser is a more elegant solution for collapsing reddit comment trees. 10 | 11 | Collapse a comment and all of it's replies by clicking on the column of the comment you wish to collapse. 12 | 13 | No longer get stuck in the middle of a huge comment chain - simply select the outermost column to collapse the whole top-level-comment. 14 | 15 | ![Screenshot1](manifest-v3/image/screenshot2.png) 16 | 17 | ![Screenshot2](manifest-v3/image/screenshot1.png) 18 | 19 | > [!NOTE] 20 | > There are currently two separate versions of this extension - manifest V2 and manifest V3. 21 | > Chrome is phasing out manifest V2, so we're forced to migrate to to avoid the extension getting removed. However, the V3 version currently doesn't seem compatible with Firefox, so V2 will be hanging around for a while. 22 | > TL;DR: Chrome = V3, Firefox = V2 23 | 24 | ## Major Contributors 25 | 26 | **Tom Watson** (original author) 27 | 28 | - 29 | 30 | **Sam A. Horvath-Hunt** 31 | 32 | - 33 | 34 | ## License 35 | 36 | Code copyright Tom Watson. Code released under [the MIT license](LICENSE.txt). 37 | -------------------------------------------------------------------------------- /manifest-v2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tom Watson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /manifest-v2/css/comment-collapser.css: -------------------------------------------------------------------------------- 1 | :root body div.sitetable div.comment { 2 | padding-left: 20px !important; 3 | position: relative !important; 4 | } 5 | 6 | :root body div.sitetable div.comment .entry { 7 | position: initial !important; 8 | } 9 | 10 | :root body div.sitetable div.comment .entry:before { 11 | width: 0 !important; 12 | } 13 | 14 | :root body div.sitetable div.comment .child { 15 | padding-left: 0 !important; 16 | margin-left: 0px !important; 17 | border-left: 0 !important; 18 | } 19 | 20 | :root body div.sitetable div.comment .midcol { 21 | margin-left: 0px !important; 22 | } 23 | 24 | :root body .expand::before, 25 | :root body .expand::after { 26 | content: initial !important; 27 | } 28 | 29 | /* Style */ 30 | :root body div.sitetable div.comment .expand { 31 | all: initial !important; 32 | background-color: rgba(255, 255, 0, 0.05) !important; 33 | border: 1px dotted rgba(0, 0, 0, 0.1) !important; 34 | border-radius: initial !important; 35 | height: 100% !important; 36 | left: 0 !important; 37 | font-size: 10px !important; 38 | margin: initial !important; 39 | padding: initial !important; 40 | position: absolute !important; 41 | top: 0 !important; 42 | width: 15px !important; 43 | text-align: center !important; 44 | transition: initial !important; 45 | } 46 | 47 | :root body div.sitetable div.comment .expand:hover { 48 | background-color: rgba(255, 255, 0, 0.3) !important; 49 | text-decoration: initial !important; 50 | } 51 | 52 | :root body.res div.sitetable div.comment .expand { 53 | border: none !important; 54 | } 55 | 56 | :root body.res-nightmode .comment .expand { 57 | color: #DDDDDD !important; 58 | } 59 | 60 | /* Retro Style */ 61 | :root body.rcc-retro div.sitetable div.comment .expand { 62 | all: initial !important; 63 | cursor: pointer !important; 64 | height: 100% !important; 65 | left: 0 !important; 66 | font-size: 10px !important; 67 | margin: initial !important; 68 | padding: initial !important; 69 | position: absolute !important; 70 | top: 0 !important; 71 | width: 15px !important; 72 | text-align: center !important; 73 | transition: initial !important; 74 | } 75 | 76 | :root body.rcc-retro div.sitetable div.comment .expand:before { 77 | content:"" !important; 78 | opacity: .4 !important; 79 | position: absolute !important; 80 | top: 20px !important; 81 | background-repeat: repeat-y !important; 82 | background-position: center !important; 83 | height: 100% !important; 84 | width: 100% !important; 85 | left: 0 !important; 86 | } 87 | 88 | :root body.rcc-retro div.sitetable div.comment .expand:hover:before { 89 | opacity: 1 !important; 90 | text-decoration: initial !important; 91 | } 92 | -------------------------------------------------------------------------------- /manifest-v2/image/collapse-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/collapse-dark.png -------------------------------------------------------------------------------- /manifest-v2/image/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/collapse.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/army.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/army.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/blue.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/brown.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/dark_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/dark_green.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/green.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/lilac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/lilac.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/navy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/navy.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/orange.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/pink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/pink.png -------------------------------------------------------------------------------- /manifest-v2/image/colours/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/colours/red.png -------------------------------------------------------------------------------- /manifest-v2/image/expand-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/expand-dark.png -------------------------------------------------------------------------------- /manifest-v2/image/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/expand.png -------------------------------------------------------------------------------- /manifest-v2/image/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/icon128.png -------------------------------------------------------------------------------- /manifest-v2/image/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/icon48.png -------------------------------------------------------------------------------- /manifest-v2/image/promo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/promo1.png -------------------------------------------------------------------------------- /manifest-v2/image/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/screenshot1.png -------------------------------------------------------------------------------- /manifest-v2/image/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v2/image/screenshot2.png -------------------------------------------------------------------------------- /manifest-v2/js/comment-collapser.js: -------------------------------------------------------------------------------- 1 | function injectRetroTheme() { 2 | // Create URLs for local files without hardcoding chrome-extension URL scheme 3 | const styleEl = document.createElement("style"); 4 | const colorsPath = chrome.runtime.getURL("image/colours"); 5 | 6 | styleEl.textContent = ` 7 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .expand:before { 8 | height: calc(100% - 20px) !important; 9 | background-image: url('${colorsPath}/red.png') !important; 10 | } 11 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .expand:before { 12 | background-image: url('${colorsPath}/orange.png') !important; 13 | } 14 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .expand:before { 15 | background-image: url('${colorsPath}/dark_green.png') !important; 16 | } 17 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .expand:before { 18 | background-image: url('${colorsPath}/blue.png') !important; 19 | } 20 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .expand:before { 21 | background-image: url('${colorsPath}/navy.png') !important; 22 | } 23 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .expand:before { 24 | background-image: url('${colorsPath}/brown.png') !important; 25 | } 26 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .expand:before { 27 | background-image: url('${colorsPath}/army.png') !important; 28 | } 29 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .comment .expand:before { 30 | background-image: url('${colorsPath}/green.png') !important; 31 | } 32 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .comment .comment .expand:before { 33 | background-image: url('${colorsPath}/pink.png') !important; 34 | } 35 | `; 36 | 37 | document.head.appendChild(styleEl); 38 | } 39 | 40 | // Based on: https://github.com/alicelieutier/smoothScroll 41 | function smoothScroll(destination) { 42 | let duration = 250; 43 | 44 | function getComputedPosition (startScroll, destination, elapsed) { 45 | if (elapsed > duration) { 46 | return destination; 47 | } else { 48 | return ( 49 | startScroll + (destination - startScroll) * 50 | (elapsed / duration) 51 | ); 52 | } 53 | } 54 | 55 | let startScroll = window.scrollY; 56 | let startTime = Date.now(); 57 | 58 | window.requestAnimationFrame(function step () { 59 | let elapsed = Date.now() - startTime; 60 | 61 | window.scroll(window.scrollX, getComputedPosition(startScroll, destination, elapsed)); 62 | 63 | if (elapsed <= duration) { 64 | window.requestAnimationFrame(step); 65 | } 66 | }); 67 | } 68 | 69 | 70 | window.addEventListener("click", function (ev) { 71 | // Only trigger for expando clicks 72 | if (!ev.target.matches(".expand")) return; 73 | 74 | let comment = ev.target.closest(".comment"); 75 | let rect = comment.getBoundingClientRect(); 76 | 77 | chrome.storage.sync.get({ 78 | collapseAnimation: true 79 | }, function(items) { 80 | 81 | // If top of comment is out of viewport, scroll to it 82 | if (rect.top < 0) { 83 | const padding = 10; 84 | let scrollPosition = (window.scrollY + rect.top) - padding; 85 | 86 | if (items.collapseAnimation) { 87 | 88 | try { 89 | // Try and use browser's smooth scrolling if available 90 | window.scroll({ 91 | top: scrollPosition, 92 | behavior: "smooth" 93 | }); 94 | } catch (e) { 95 | // Fallback 96 | smoothScroll(scrollPosition); 97 | } 98 | 99 | } else { 100 | 101 | window.scrollTo(null, scrollPosition); 102 | 103 | } 104 | 105 | } 106 | }); 107 | }); 108 | 109 | document.addEventListener("DOMContentLoaded", function(event) { 110 | 111 | chrome.storage.sync.get({ 112 | style: 'minimalist' 113 | }, function(items) { 114 | 115 | if (items.style === 'minimalist') { 116 | 117 | document.body.classList.add('rcc-minimalist'); 118 | 119 | } else { 120 | 121 | document.body.classList.add('rcc-retro'); 122 | injectRetroTheme(); 123 | 124 | } 125 | 126 | }); 127 | 128 | }); 129 | -------------------------------------------------------------------------------- /manifest-v2/js/options.js: -------------------------------------------------------------------------------- 1 | // Saves options to chrome.storage.sync. 2 | function save_options() { 3 | 4 | var style = document.getElementById('style').value; 5 | var collapseAnimation = document.getElementById('collapseAnimation').checked; 6 | 7 | chrome.storage.sync.set({ 8 | style: style, 9 | collapseAnimation: collapseAnimation 10 | }, function() { 11 | 12 | // Update status to let user know options were saved. 13 | var status = document.getElementById('status'); 14 | status.textContent = 'Options saved.'; 15 | setTimeout(function() { 16 | status.textContent = ''; 17 | }, 1000); 18 | 19 | }); 20 | 21 | } 22 | 23 | function restore_options() { 24 | 25 | chrome.storage.sync.get({ 26 | style: 'minimalist', 27 | collapseAnimation: true 28 | }, function(items) { 29 | 30 | document.getElementById('style').value = items.style; 31 | document.getElementById('collapseAnimation').checked = items.collapseAnimation; 32 | 33 | }); 34 | 35 | } 36 | 37 | document.addEventListener('DOMContentLoaded', restore_options); 38 | document.getElementById('save').addEventListener('click', save_options); 39 | -------------------------------------------------------------------------------- /manifest-v2/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5.1.2", 3 | "applications": { 4 | "gecko": { 5 | "id": "{a5b2e636-07e5-4331-93c1-6cf4074356c8}", 6 | "strict_min_version": "42.0" 7 | } 8 | }, 9 | "manifest_version": 2, 10 | "minimum_chrome_version": "41.0.2272.76", 11 | "name": "Reddit Comment Collapser", 12 | "description": "A more elegant solution for collapsing reddit comment trees", 13 | "icons": { 14 | "48" : "image/icon48.png", 15 | "128": "image/icon128.png" 16 | }, 17 | "content_scripts": [{ 18 | "matches": [ 19 | "http://*.reddit.com/*/comments/*", 20 | "https://*.reddit.com/*/comments/*" 21 | ], 22 | "css": ["css/comment-collapser.css"], 23 | "js": ["js/comment-collapser.js"], 24 | "run_at": "document_start" 25 | }], 26 | "web_accessible_resources": [ 27 | "image/collapse.png", 28 | "image/collapse-dark.png", 29 | "image/expand.png", 30 | "image/expand-dark.png", 31 | "image/colours/*" 32 | ], 33 | "permissions": [ 34 | "storage", 35 | "https://*.reddit.com/" 36 | ], 37 | "options_ui": { 38 | "page": "views/options.html", 39 | "chrome_style": true 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /manifest-v2/views/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Reddit Comment Collapser Options 5 | 8 | 9 | 10 | 11 |
12 | 13 | 17 |
18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /manifest-v3/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tom Watson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /manifest-v3/Makefile: -------------------------------------------------------------------------------- 1 | reddit-comment-collapser.zip: js/*.js *.json views/*.html css/*.css image/**/*.png 2 | zip -r reddit-comment-collapser.zip * -x img/screenshot* -x .gitignore -x Makefile 3 | -------------------------------------------------------------------------------- /manifest-v3/css/comment-collapser.css: -------------------------------------------------------------------------------- 1 | :root body div.sitetable div.comment { 2 | padding-left: 20px !important; 3 | position: relative !important; 4 | } 5 | 6 | :root body div.sitetable div.comment .entry { 7 | position: initial !important; 8 | } 9 | 10 | :root body div.sitetable div.comment .entry:before { 11 | width: 0 !important; 12 | } 13 | 14 | :root body div.sitetable div.comment .child { 15 | padding-left: 0 !important; 16 | margin-left: 0px !important; 17 | border-left: 0 !important; 18 | } 19 | 20 | :root body div.sitetable div.comment .midcol { 21 | margin-left: 0px !important; 22 | } 23 | 24 | :root body .expand::before, 25 | :root body .expand::after { 26 | content: initial !important; 27 | } 28 | 29 | /* Style */ 30 | :root body div.sitetable div.comment .expand { 31 | all: initial !important; 32 | background-color: rgba(255, 255, 0, 0.05) !important; 33 | border: 1px dotted rgba(0, 0, 0, 0.1) !important; 34 | border-radius: initial !important; 35 | height: 100% !important; 36 | left: 0 !important; 37 | font-size: 10px !important; 38 | margin: initial !important; 39 | padding: initial !important; 40 | position: absolute !important; 41 | top: 0 !important; 42 | width: 15px !important; 43 | text-align: center !important; 44 | transition: initial !important; 45 | } 46 | 47 | :root body div.sitetable div.comment .expand:hover { 48 | background-color: rgba(255, 255, 0, 0.3) !important; 49 | text-decoration: initial !important; 50 | } 51 | 52 | :root body.res div.sitetable div.comment .expand { 53 | border: none !important; 54 | } 55 | 56 | :root body.res-nightmode .comment .expand { 57 | color: #DDDDDD !important; 58 | } 59 | 60 | /* Retro Style */ 61 | :root body.rcc-retro div.sitetable div.comment .expand { 62 | all: initial !important; 63 | cursor: pointer !important; 64 | height: 100% !important; 65 | left: 0 !important; 66 | font-size: 10px !important; 67 | margin: initial !important; 68 | padding: initial !important; 69 | position: absolute !important; 70 | top: 0 !important; 71 | width: 15px !important; 72 | text-align: center !important; 73 | transition: initial !important; 74 | } 75 | 76 | :root body.rcc-retro div.sitetable div.comment .expand:before { 77 | content:"" !important; 78 | opacity: .4 !important; 79 | position: absolute !important; 80 | top: 20px !important; 81 | background-repeat: repeat-y !important; 82 | background-position: center !important; 83 | height: 100% !important; 84 | width: 100% !important; 85 | left: 0 !important; 86 | } 87 | 88 | :root body.rcc-retro div.sitetable div.comment .expand:hover:before { 89 | opacity: 1 !important; 90 | text-decoration: initial !important; 91 | } 92 | -------------------------------------------------------------------------------- /manifest-v3/image/collapse-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/collapse-dark.png -------------------------------------------------------------------------------- /manifest-v3/image/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/collapse.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/army.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/army.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/blue.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/brown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/brown.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/dark_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/dark_green.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/green.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/lilac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/lilac.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/navy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/navy.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/orange.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/pink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/pink.png -------------------------------------------------------------------------------- /manifest-v3/image/colours/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/colours/red.png -------------------------------------------------------------------------------- /manifest-v3/image/expand-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/expand-dark.png -------------------------------------------------------------------------------- /manifest-v3/image/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/expand.png -------------------------------------------------------------------------------- /manifest-v3/image/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/icon128.png -------------------------------------------------------------------------------- /manifest-v3/image/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/icon48.png -------------------------------------------------------------------------------- /manifest-v3/image/promo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/promo1.png -------------------------------------------------------------------------------- /manifest-v3/image/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/screenshot1.png -------------------------------------------------------------------------------- /manifest-v3/image/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tom-james-watson/reddit-comment-collapser/9c660c2c02e86b24822e29a5542ea648748fcc0f/manifest-v3/image/screenshot2.png -------------------------------------------------------------------------------- /manifest-v3/js/comment-collapser.js: -------------------------------------------------------------------------------- 1 | function injectRetroTheme() { 2 | // Create URLs for local files without hardcoding chrome-extension URL scheme 3 | const styleEl = document.createElement("style"); 4 | const colorsPath = chrome.runtime.getURL("image/colours"); 5 | 6 | styleEl.textContent = ` 7 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .expand:before { 8 | height: calc(100% - 20px) !important; 9 | background-image: url('${colorsPath}/red.png') !important; 10 | } 11 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .expand:before { 12 | background-image: url('${colorsPath}/orange.png') !important; 13 | } 14 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .expand:before { 15 | background-image: url('${colorsPath}/dark_green.png') !important; 16 | } 17 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .expand:before { 18 | background-image: url('${colorsPath}/blue.png') !important; 19 | } 20 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .expand:before { 21 | background-image: url('${colorsPath}/navy.png') !important; 22 | } 23 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .expand:before { 24 | background-image: url('${colorsPath}/brown.png') !important; 25 | } 26 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .expand:before { 27 | background-image: url('${colorsPath}/army.png') !important; 28 | } 29 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .comment .expand:before { 30 | background-image: url('${colorsPath}/green.png') !important; 31 | } 32 | :root body.rcc-retro div.sitetable div.comment.noncollapsed .comment .comment .comment .comment .comment .comment .comment .comment .expand:before { 33 | background-image: url('${colorsPath}/pink.png') !important; 34 | } 35 | `; 36 | 37 | document.head.appendChild(styleEl); 38 | } 39 | 40 | // Based on: https://github.com/alicelieutier/smoothScroll 41 | function smoothScroll(destination) { 42 | let duration = 250; 43 | 44 | function getComputedPosition (startScroll, destination, elapsed) { 45 | if (elapsed > duration) { 46 | return destination; 47 | } else { 48 | return ( 49 | startScroll + (destination - startScroll) * 50 | (elapsed / duration) 51 | ); 52 | } 53 | } 54 | 55 | let startScroll = window.scrollY; 56 | let startTime = Date.now(); 57 | 58 | window.requestAnimationFrame(function step () { 59 | let elapsed = Date.now() - startTime; 60 | 61 | window.scroll(window.scrollX, getComputedPosition(startScroll, destination, elapsed)); 62 | 63 | if (elapsed <= duration) { 64 | window.requestAnimationFrame(step); 65 | } 66 | }); 67 | } 68 | 69 | 70 | window.addEventListener("click", function (ev) { 71 | // Only trigger for expando clicks 72 | if (!ev.target.matches(".expand")) return; 73 | 74 | let comment = ev.target.closest(".comment"); 75 | let rect = comment.getBoundingClientRect(); 76 | 77 | chrome.storage.sync.get({ 78 | collapseAnimation: true 79 | }, function(items) { 80 | 81 | // If top of comment is out of viewport, scroll to it 82 | if (rect.top < 0) { 83 | const padding = 10; 84 | let scrollPosition = (window.scrollY + rect.top) - padding; 85 | 86 | if (items.collapseAnimation) { 87 | 88 | try { 89 | // Try and use browser's smooth scrolling if available 90 | window.scroll({ 91 | top: scrollPosition, 92 | behavior: "smooth" 93 | }); 94 | } catch (e) { 95 | // Fallback 96 | smoothScroll(scrollPosition); 97 | } 98 | 99 | } else { 100 | 101 | window.scrollTo(null, scrollPosition); 102 | 103 | } 104 | 105 | } 106 | }); 107 | }); 108 | 109 | document.addEventListener("DOMContentLoaded", function(event) { 110 | 111 | chrome.storage.sync.get({ 112 | style: 'minimalist' 113 | }, function(items) { 114 | 115 | if (items.style === 'minimalist') { 116 | 117 | document.body.classList.add('rcc-minimalist'); 118 | 119 | } else { 120 | 121 | document.body.classList.add('rcc-retro'); 122 | injectRetroTheme(); 123 | 124 | } 125 | 126 | }); 127 | 128 | }); 129 | -------------------------------------------------------------------------------- /manifest-v3/js/options.js: -------------------------------------------------------------------------------- 1 | // Saves options to chrome.storage.sync. 2 | function save_options() { 3 | 4 | var style = document.getElementById('style').value; 5 | var collapseAnimation = document.getElementById('collapseAnimation').checked; 6 | 7 | chrome.storage.sync.set({ 8 | style: style, 9 | collapseAnimation: collapseAnimation 10 | }, function() { 11 | 12 | // Update status to let user know options were saved. 13 | var status = document.getElementById('status'); 14 | status.textContent = 'Options saved.'; 15 | setTimeout(function() { 16 | status.textContent = ''; 17 | }, 1000); 18 | 19 | }); 20 | 21 | } 22 | 23 | function restore_options() { 24 | 25 | chrome.storage.sync.get({ 26 | style: 'minimalist', 27 | collapseAnimation: true 28 | }, function(items) { 29 | 30 | document.getElementById('style').value = items.style; 31 | document.getElementById('collapseAnimation').checked = items.collapseAnimation; 32 | 33 | }); 34 | 35 | } 36 | 37 | document.addEventListener('DOMContentLoaded', restore_options); 38 | document.getElementById('save').addEventListener('click', save_options); 39 | -------------------------------------------------------------------------------- /manifest-v3/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "6.0.1", 3 | "manifest_version": 3, 4 | "minimum_chrome_version": "88", 5 | "name": "Reddit Comment Collapser", 6 | "description": "A more elegant solution for collapsing reddit comment trees", 7 | "icons": { 8 | "48": "image/icon48.png", 9 | "128": "image/icon128.png" 10 | }, 11 | "content_scripts": [ 12 | { 13 | "matches": [ 14 | "http://*.reddit.com/*/comments/*", 15 | "https://*.reddit.com/*/comments/*" 16 | ], 17 | "css": ["css/comment-collapser.css"], 18 | "js": ["js/comment-collapser.js"], 19 | "run_at": "document_start" 20 | } 21 | ], 22 | "web_accessible_resources": [ 23 | { 24 | "resources": [ 25 | "image/collapse.png", 26 | "image/collapse-dark.png", 27 | "image/expand.png", 28 | "image/expand-dark.png", 29 | "image/colours/*" 30 | ], 31 | "matches": [""] 32 | } 33 | ], 34 | "permissions": ["storage"], 35 | "options_ui": { 36 | "page": "views/options.html" 37 | }, 38 | "host_permissions": ["https://*.reddit.com/"] 39 | } 40 | -------------------------------------------------------------------------------- /manifest-v3/views/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Reddit Comment Collapser Options 5 | 8 | 9 | 10 | 11 |
12 | 13 | 17 |
18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | --------------------------------------------------------------------------------