Adds level back to the dashboard header
当前为
// ==UserScript==
// @name Wanikani: Dashboard Level
// @namespace http://tampermonkey.net/
// @version 1.1.1
// @description Adds level back to the dashboard header
// @author Kumirei
// @include https://www.wanikani.com*
// @include *preview.wanikani.com*
// @grant none
// ==/UserScript==
(function() {
let header = document.getElementsByClassName('global-header')[0];
if (!header) return;
let level = document.getElementsByClassName('user-summary__attribute')[0].children[0].href.split('/level/')[1];
let subscription = document.getElementsByClassName('user-summary__attribute')[1].children[0].innerHTML.trim();
let color = '#f1f3f5';
if (subscription == "Lifetime") color = '#d580ff';
if (subscription == "Recurring") color = '#80d5ff';
if (level==60) color = '#fbc042';
header.getElementsByClassName('sitemap__section-header--account')[0].insertAdjacentHTML('beforebegin', '<div class="dashboard-level"><span>'+level+'</span></div>');
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
<style id="DashboardLevelCSS">
.dashboard-level {
width: 19px;
height: 19px;
z-index: 1;
position: absolute;
right: 5px;
transform: translateX(50%);
bottom: -10px;
border-radius: 100%;
text-align: center;
background: ${color};
}
.dashboard-level > span {
color: rgb(240, 240, 240) !important;
text-shadow: 1px 1px rgba(42, 42, 42, 0.5) !important;
font-size: 12px;
font-weight: bold;
display: block;
}
</style>`);
})();