Last active
February 13, 2020 11:42
-
-
Save StephanStanisic/c687fd5aa198187a31692283e3fd3218 to your computer and use it in GitHub Desktop.
Userscript for nice tasker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Tasker UI update | |
// @namespace https://stephanstanisic.nl/ | |
// @version 0.6 | |
// @description Adds some js/css to tasker's ui to make it usable | |
// @author Stephan Stanisic | |
// @match https://studychain.nl/* | |
// @grant none | |
// @updateURL https://gist.github.com/StephanStanisic/c687fd5aa198187a31692283e3fd3218/raw/tasker.user.js | |
// @downloadURL https://gist.github.com/StephanStanisic/c687fd5aa198187a31692283e3fd3218/raw/tasker.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
/* | |
This code is a mess. Yes I know. | |
Enjoy it, the ppl of tasker didn't add | |
any logical classes to the page elements | |
so here we go. | |
*/ | |
let style = document.createElement("style"); | |
style.innerHTML = ` | |
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap'); | |
* { font-family: 'Roboto', sans-serif }\ | |
code * { font-family: monospace; } | |
nav > a > img:nth-child(1) { margin-right: 0.6em; padding-right: 0.4em; } | |
.feedback__stack { bottom: 0; top: unset; } | |
.list-group-item { text-align: left } | |
.toast { box-shadow: none; border: 2px solid rgba(0,0,0,.1); } | |
.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto { width: 100% !important; max-width: 100% !important; float: unset !important; flex: 0 0 1 !important; } | |
#navbarSupportedContent { float: right; } | |
hr { display: none } | |
.text-secondary { margin-top: 3em } | |
h3 { margin: 2em 0; } | |
.row { display: block !important; } | |
.container { text-align: center; max-width: 800px; } | |
body[class^="/dashboard/task"] .container { text-align: left } | |
body[class^="/dashboard "] .navbar.navbar-expand-lg.navbar-light.bg-light { margin-bottom: 4em; } | |
.task__content { padding:0; border: 0; text-align:left; } | |
.container .btn.btn-primary.btn-sm[href="/dashboard"] { position: absolute; top: 1em; left: 10em; } | |
.container .btn.btn-success.btn-sm.mt-1.mt-lg-0[href^="/dashboard/task/"] { position: fixed; bottom: 2em; right: 2em; } | |
.task__content h1 { font-size: 1.6em; padding: 1.2em 0 0.6em 0; } | |
.task__content h2 { font-size: 1.4em; padding: 1.2em 0 0.6em 0; } | |
.task__content h3 { font-size: 1.2em; padding: 1.2em 0 0.6em 0; } | |
.task__content h4 { font-size: 1em; padding: 1.2em 0 0.6em 0; } | |
img { max-width: 100% } | |
footer { display: none !important } | |
pre > code { display: block; padding: 0.8em 1.2em !important; border-radius: 0.2em; } | |
`; | |
style.id = "custom_styles"; | |
let page_loop = () => { | |
if(document.body && !document.getElementById(style.id)) document.body.appendChild(style); | |
[].slice.call(document.getElementsByClassName("task__button")).forEach(elem => { | |
if(elem.style.boxShadow != "none") { | |
let color = elem.style.boxShadow.substr(0, 18); | |
if(elem.className.indexOf("task__button--completed") > -1) { | |
elem.style.opacity = 0.2; | |
} | |
elem.style.background = color; | |
elem.style.boxShadow = "none"; | |
} | |
}); | |
[].slice.call(document.getElementsByClassName("btn btn-primary btn-sm mt-1 mt-lg-0")).forEach(elem => { | |
if(elem.innerText.substr(0, 8) == "Volgende") { | |
elem.style.cssText = "position:fixed;top:50%;right:1em;transform:translateY(-50%); color:#444; font-size: 2em;"; | |
elem.className = "fa fa-angle-right"; | |
elem.innerHTML = ""; | |
} else if(elem.innerText.substr(0, 8) == " Vorige ") { | |
elem.style.cssText = "position:fixed;top:50%;left:1em;transform:translateY(-50%); color:#444; font-size: 2em;"; | |
elem.className = "fa fa-angle-left"; | |
elem.innerHTML = ""; | |
} | |
}); | |
try { | |
if(document.getElementsByClassName("task__content")[0].children[0].innerText.trim().substr(0, 2) == "**") { | |
document.getElementsByClassName("task__content")[0].children[0].style.display = "none"; | |
} | |
} catch (e) {}; | |
} | |
setInterval(page_loop, 1000); | |
page_loop(); | |
addEventListener("load", function(){ | |
setTimeout(function(){ | |
document.body.classList.add("loaded"); | |
}, 10); | |
if(location.pathname == "/home/student" && document.getElementsByClassName("list-group-item").length == 1) { | |
document.getElementsByClassName("list-group-item")[0].parentElement.click(); | |
} | |
document.body.classList.add(location.pathname) | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wtf maat