Skip to content

Instantly share code, notes, and snippets.

@tacostea
Last active July 5, 2020 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacostea/bc7c248926b4db5f9c7a7c189eeb980b to your computer and use it in GitHub Desktop.
Save tacostea/bc7c248926b4db5f9c7a7c189eeb980b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name NicoNico Header
// @namespace http://tampermonkey.net/
// @version 0.2
// @description none
// @author tacostea
// @match www.nicovideo.jp/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
Element.prototype.insertHeader = function(href, label){
var parent = this.parentNode;
var newElm = document.createElement('a');
newElm.id = 'siteHeader';
newElm.class = 'nico-CommonHeaderRoot'
newElm.setAttribute('href', href);
newElm.innerText = label;
parent.insertBefore(newElm, this);
}
window.onload = window.setTimeout( function(){
if(document.querySelector('li.siteHeaderHorizon')){return;}
var refElm = document.querySelectorAll('a[href*="prem"]')[0];
refElm.insertHeader('/my/top', 'マイページ');
refElm.insertHeader('/recommendations', 'オススメ');
refElm.insertHeader('https://www.upload.nicovideo.jp/garage/upload', '動画投稿');
refElm.insertHeader('/ranking', 'ランキング');
var e = document.createElement('style');
e.innerText = `a#siteHeader{
position: relative;
text-decoration: none;
cursor: pointer;
line-height: 36px;
height: 36px;
display: flex;
-moz-box-align: center;
align-items: center;
font-size: 12px;
width: auto;
padding: 0px 6px;
color: rgb(255, 255, 255);
}
a[href*='/my?']{
display:none!important
}`;
document.head.appendChild(e);
}, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment