Mirkoplugin

Robi dobrze

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Mirkoplugin
// @namespace   http://localhost/
// @description Robi dobrze
// @include     http://www.wykop.pl/*
// @version     1
// @grant       GM_addStyle
// ==/UserScript==

var getClass = function(clssName, rootNode /*optional root node to start search from*/){

  var root = rootNode || document,
      clssEls = [],
      elems,
      clssReg = new RegExp("\\b"+clssName+"\\b");

  // use the built in getElementsByClassName if available
  if (document.getElementsByClassName){
    return root.getElementsByClassName(clssName);
  }
  
  // otherwise loop through all(*) nodes and add matches to clssEls
  elems = root.getElementsByTagName('*');
  for (var i = 0, len = elems.length; i < len; i+=1){
    if (clssReg.test(elems[i].className)) clssEls.push(elems[i])
  }

  return clssEls;
  
};

GM_addStyle ( "\
    .content-box {\
        background-color: transparent;\
        width: 100px;\
        height: 22px;\
        overflow: hidden;\
        z-index: 5;\
        margin: 0 auto;\
    }\
    .p-up {\
    	text-align: center;\
    	line-height: 22px;\
    }\
" );

function addDiv(){
	var x = 0;
	var post= getClass('entry iC');
	while(x < post.length){
	var newHTML         = document.createElement('div');
	newHTML.className = "plugin-container";
	newHTML.innerHTML   = '             \
    	<div class="content-box">             \
        	<a><p class="p-up"><i class="fa fa-chevron-up"></i> Do Góry</p></a>       \
    	</div>                          \
	';
	post[x].appendChild(newHTML);
	getClass('plugin-container')[x].addEventListener("click", function(){
		window.scrollTo(0, this.parentElement.offsetTop - 50);
	});
	x++;
	//document.querySelector('.entry.iC').appendChild(newHTML);
}

}

addDiv();