Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dideler committed Aug 3, 2016
0 parents commit 2572c7f
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
|<h2>Toggle YouTube Comments</h2><br>![](icons/128.png)|
|:---:|
|It's dangerous to go alone. Take this.<br>Collapses YouTube comments by default.|
|_<sup>Extension listens for [SPF events] which are YouTube specific.</sup><br><sup>Icon by [Gregor Cresnar]. Licensed under [CC BY 3.0].</sup>_|


[SPF events]: https://youtube.github.io/spfjs/documentation/events/
[Gregor Cresnar]: http://www.flaticon.com/authors/gregor-cresnar
[CC BY 3.0]: http://creativecommons.org/licenses/by/3.0/ "Creative Commons Attribution 3.0 Unported"
3 changes: 3 additions & 0 deletions bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

zip -9 -r $(date +%F)-toggle-youtube-comments.zip . -x "*.git*" "*.md" "$0"
Binary file added icons/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"manifest_version": 2,
"name": "Toggle YouTube Comments",
"description": "Be safe. Hide YouTube comments.",
"version": "1.0.0",

"icons": {
"16": "icons/16.png",
"32": "icons/32.png",
"128": "icons/128.png"
},

"content_scripts": [
{
"matches": ["http://*.youtube.com/*", "https://*.youtube.com/*"],
"js": ["script.js"],
"css": ["youtube.css"],
"run_at": "document_start"
}
]
}
36 changes: 36 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

function toggleComments() {
var label = document.getElementById('toggle-comments').firstElementChild;
var comments = document.getElementById('watch-discussion');
if (comments.classList.toggle('hide-comments')) {
label.textContent = 'Show comments';
} else {
label.textContent = 'Hide comments';
}
}

function inject() {
addClass();
addButton();
}

function addClass() {
document.getElementById('watch-discussion').className += ' hide-comments';
}

function addButton() {
var button =`
<button class="yt-uix-button yt-uix-button-size-default yt-uix-button-expander" id="toggle-comments" type="button">
<span class="yt-uix-button-content">Show comments</span>
</button>
`;

document.getElementById('action-panel-details').innerHTML += button;
document.getElementById('toggle-comments').addEventListener('click', toggleComments);
}

(function () {
document.addEventListener('DOMContentLoaded', inject); // Static navigation (i.e. initial page load)
document.addEventListener('spfdone', inject); // Dynamic navigation (i.e. subsequent page loads)
})();
1 change: 1 addition & 0 deletions youtube.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.hide-comments { display: none !important }

0 comments on commit 2572c7f

Please sign in to comment.