Puts the lessons and review counts back into the header
目前為
// ==UserScript==
// @name Wanikani: Lessons & Reviews in header
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Puts the lessons and review counts back into the header
// @author Kumirei
// @include /^https://(www|preview).wanikani.com/(dashboard)?$/
// @grant none
// ==/UserScript==
(function() {
addCSS();
moveToHeader("Review");
moveToHeader("Lesson");
function moveToHeader(type) {
let originalElem = document.getElementsByClassName(`lessons-and-reviews__${type.toLowerCase()}s-button`)[0];
let count = originalElem.children[0].innerText;
document.getElementsByClassName('sitemap')[0].insertAdjacentHTML('afterBegin', `
<li class="sitemap__section dashboard-lessons-reviews-section">
<span class="dashboard-reviews" data-count="${count}">${count}</span>
<a class="sitemap__section-header" href="/${type.toLowerCase()}">
<span lang="en">${type}s</span>
</a>
</li>
`);
originalElem.remove();
}
function addCSS() {
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeEnd', `
<style id="header-lessons-reviews-css">
.dashboard,
.progress-and-forecast,
.dashboard-progress {
grid-row: 1/3 !important;
}
.sitemap .sitemap__section.dashboard-lessons-reviews-section a {
display: inline-block;
border: 2px solid rgba(0,0,0,0.1);
border-left: 0;
padding-left: 11px;
border-radius: 0 4px 4px 0;
}
.sitemap .sitemap__section.dashboard-lessons-reviews-section {
font-size: 0;
}
.dashboard-reviews,
.dashboard-lessons {
background-color: #a0f;
min-width: 16px;
padding: 0 8px;
font-size: 0.75rem;
display: inline-block;
vertical-align: top;
border-radius: 4px 0 0 4px;
line-height: 32px;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
font-weight: bold;
text-align: center;
}
.dashboard-reviews[data-count="0"],
.dashboard-lessons[data-count="0"] {
background-color: #aaa;
}
</style>
`);
}
})();