aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2017-06-23 01:51:14 +0530
committerArun Isaac2017-06-23 01:51:14 +0530
commit698461c04d7d2f1e67f1edf97c1dc1248a39f053 (patch)
tree7bf4aa8e1f7aaf1605970f68d5bed85870c6d19b
downloadyoutube-noscript-shim-698461c04d7d2f1e67f1edf97c1dc1248a39f053.tar.gz
youtube-noscript-shim-698461c04d7d2f1e67f1edf97c1dc1248a39f053.tar.lz
youtube-noscript-shim-698461c04d7d2f1e67f1edf97c1dc1248a39f053.zip
Initial commit.
-rw-r--r--youtube-noscript-shim.user.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/youtube-noscript-shim.user.js b/youtube-noscript-shim.user.js
new file mode 100644
index 0000000..cac6d45
--- /dev/null
+++ b/youtube-noscript-shim.user.js
@@ -0,0 +1,39 @@
+// ==UserScript==
+// @name youtube-noscript-shim
+// @namespace systemreboot.net
+// @description Use YouTube with NoScript
+// @include https://www.youtube.com/*
+// @version 0.1
+// @grant none
+// ==/UserScript==
+
+function toggleClasses (selector, classes) {
+ classes.forEach(function (cls) {
+ document.querySelector(selector).classList.toggle(cls);
+ });
+}
+
+function toggleBooleanAttributes (selector, attributes) {
+ element = document.querySelector(selector);
+ attributes.forEach(function (attribute) {
+ element.setAttribute(attribute, element.getAttribute(attribute) == "true" ? "false" : "true");
+ });
+}
+
+// Load thumbnails
+Array.from(document.querySelectorAll("img[data-thumb]")).forEach(function (img) {
+ img.setAttribute("src", img.getAttribute("data-thumb"));
+});
+
+// Search filters
+document.querySelector(".filter-button").addEventListener("click", function () {
+ toggleClasses(".filter-button", ["yt-uix-button-toggled"]);
+ toggleClasses(".search-header", ["yt-uix-expander-collapsed"]);
+ toggleBooleanAttributes(".filter-button", ["aria-pressed"]);
+});
+
+// Guide
+document.querySelector("#appbar-guide-button").addEventListener("click", function () {
+ toggleClasses("html", ["show-guide"]);
+ toggleBooleanAttributes("#appbar-guide-button", ["aria-expanded"]);
+});