Add breadcrumbs on PotPlayer's forum
当前为
// ==UserScript==
// @name PotPlayer forum breadcrumbs
// @namespace V@no
// @description Add breadcrumbs on PotPlayer's forum
// @include https://potplayer.daum.net/forum/*
// @version 1.3
// @grant none
// ==/UserScript==
var inToolbar = true; //show it at top toolbar? (true or false)
var bc = document.getElementsByClassName("btn-breadcrumb"),
style = document.createElement("style"),
css;
function $(id)
{
return document.getElementById(id);
}
function log(t)
{
console.log(t);
}
inToolbar = inToolbar && bc.length && $("search");
if (inToolbar)
{
//set link on logo to home page
document.getElementsByClassName("navbar-header")[0].getElementsByTagName("a")[0].setAttribute("href", "../");
//insert breadcrumbs to top toolbar
$("search").parentNode.insertBefore(bc[0], $("search").nextSibling);
css = function(){/*
/* center breadcrumbs in the toolbar *//*
.btn-breadcrumb
{
margin-top: 8px;
margin-left: -10px;
}
/* move everything else down *//*
#content-wrapper
{
margin-top: 40px;
}
*/};
}
else
{
css = function(){/*
/* disallow menu bar wrap if it doesn't fit into window *//*
.navbar-fixed-top
{
max-height: 50px;
}
/* move everything else down *//*
#content-wrapper
{
margin-top: 50px;
}
/* make breadcrumbs at fixed position so it always visible *//*
.btn-breadcrumb
{
position: fixed;
z-index: 9999;
}
*/};
}
style.innerHTML = css.toString().slice(14,-3).replace(/\*\/\/\*/g, "*/");
document.getElementsByTagName("head")[0].appendChild(style);
//http://t1.daumcdn.net/potplayer/beta/PotPlayerSetup.exe
let menu = $("main-menu");
if (menu)
{
let nav, ul, lis;
if ((nav = document.evaluate('.//nav[@class="navbar navbar-default navbar-fixed-bottom hidden-sm hidden-xs"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0))
&& (ul = nav.getElementsByTagName("ul")[0])
&& (lis = ul.getElementsByTagName("li")).length)
{
let li = document.createElement("li"),
a = document.createElement("a");
li.appendChild(a);
a.href = "http://t1.daumcdn.net/potplayer/beta/PotPlayerSetup.exe";
a.innerHTML = '<i class="fa fa-download"></i> Latest Beta';
ul.appendChild(li);
}
let found = false,
pass = $("navloginform");
if (pass)
{
let inputs = pass.getElementsByTagName("input");
for(let i = 0; i < inputs.length; i++)
{
if (inputs[i].name == "autologin")
found = i;
if (inputs[i].name == "password")
pass = inputs[i];
}
if (found === false)
{
let checkbox = document.createElement("div");
checkbox.className = "checkbox";
checkbox.innerHTML = '<label for="autologin"><input name="autologin" id="autologin" tabindex="4" type="checkbox"> Log me on automatically each visit</label><br><label for="viewonline"><input name="viewonline" id="viewonline" tabindex="5" type="checkbox"> Hide my online status this session</label>';
$("navloginform").insertBefore(checkbox, pass.nextSibling);
}
}
}