TOC_Lista ludopedia

Mostra um TOC para os itens de uma lista da ludopedia (somente local)

目前為 2016-08-01 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name TOC_Lista ludopedia
// @namespace tequila_j-script
// @version    0.2.0
// @description  Mostra um TOC para os itens de uma lista da ludopedia (somente local)
// @match      http://*.ludopedia.com.br/lista/*
// @match      http://ludopedia.com.br/lista/*
// @match      https://*.ludopedia.com.br/lista/*
// @match      https://ludopedia.com.br/lista/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant    GM_addStyle
// @run-at document-end
// ==/UserScript==


GM_addStyle("\
div.principal {\
	position: relative;\
}\
\
div.toc {\
	position: absolute;\
	top: -50px;\
	//bottom: 0px;\
	right: -330px;\
	//left: 0px;\
	width: 350px;\
	max-height: 80%;\
    margin: auto;\
	box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\
    background: rgba(240,240,253,0.90);\
    padding: 8px 8px;\
    border-radius: 8px;\
}\
\
div.toc div.inner-panel {\
	position: relative;\
}\
div.toc div.pag-panel {\
	position: absolute;\
	top:-25px;\
	right:0px;\
}\
div.toc div.list-panel {\
	overflow:auto;\
	margin:2px 0px;\
	border-bottom: 1px solid white;\
}\
div.toc p {\
	margin:2px 0px;\
	border-bottom: 1px solid white;\
}\
div.toc p:hover {\
	background: rgba(220,220,253,0.90);\
}\
\
div.toc p span {\
	cursor: pointer;\
	cursor: hand;\
	font-size: small;\
	padding: 0px;\
}\
div.toc p span.bid {\
	cursor: pointer;\
	cursor: hand;\
}\
div.toc p span.name {\
	cursor: pointer;\
	cursor: hand;\
}\
\
div.toc .panel {\
}\
\
div.toc .misc\
{\
    position: absolute;\
    top: 103%;\
    left: 0;\
    width: 100%;\
}\
div.toc .micropagination {\
	font-size: x-small;\
}\
div.toc ul.micropagination {\
	font-size: x-small;\
	display:inline-block;\
	width: 100%;\
	text-align: right;\
}\
div.toc .micropagination li {\
	display: inline;\
	padding: 0px 8px;\
}\
div.toc .micropagination li.active {\
	border: 1px solid lightgray;\
}\
div.toc .micropagination li.disabled a {\
   	color: rgb(220,230,243);\
}\
");


var $items = $('div[id^="id_ludo_list_item_"');

var itemsObject = new Array();

$items.each(function () {
  var itemHeader = $(this).find('.panel-title > div.pull-left > a');
  var itemName = $(itemHeader[1]).html();
  var itemAnchor = $(itemHeader[0]).attr('href');
  var itemObject = {
    'name' : itemName,
    'anchor' : itemAnchor,
    'id' : $(this).attr('id')
  }
  
  //does it have an alternate name?
  var itemBody = $(this).find('div.lista-item-descricao').text();
  var alternateNameLine = itemBody.match(/\+\+.*\+\+/)
  if (alternateNameLine != null) {
    console.log(alternateNameLine);
    var parts = alternateNameLine[0].substring(2,alternateNameLine[0].length - 4).trim();
    itemObject.name = parts;
  }
  
  itemsObject.push(itemObject)
});


//create the small box
var $tocEl = $(document.createElement('div')).addClass("toc");
var $tocInnerPanel = $(document.createElement('div')).addClass("inner-panel");
var $tocPagPanel = $(document.createElement('div')).addClass("pag-panel");
var $tocListPanel = $(document.createElement('div')).addClass("list-panel");
var $tocPanel = $(document.createElement('div'));

$tocEl.append($tocInnerPanel);
$tocInnerPanel.append($tocPagPanel);
$tocInnerPanel.append($tocListPanel);
$('div.principal').append($tocEl);

$tocListPanel.css("max-height",window.innerHeight - 200);
$(window).resize(function() {
  $tocListPanel.css( "max-height",window.innerHeight - 200);
});

//scrolling
$(window).scroll(function(){            
	$tocEl
    .stop()
	.animate({"marginTop": ($(window).scrollTop() )}, "fast" );         
  
});


//cria a lista de TOC
itemsObject.forEach(function(item) {
  
  var tocEntry = $(document.createElement('p'));
  var tocName = $(document.createElement('span')).addClass('name');
  var tocValue = $(document.createElement('span')).addClass('bid');
  
  tocName.html(item.name);
  tocValue.html('$ - ');
  
  tocEntry.append(tocValue).append(tocName);
  
  $tocListPanel.append(tocEntry);
  
  tocName.click(function() {
    var listItem = document.getElementById(item.id);
    $('html, body').stop().animate({
     'scrollTop': $(listItem).offset().top
	}, 900);
    
  });
  
  tocValue.click(function() {
    var listItem = document.getElementById(item.id);
    var value = $(listItem).find('.bloco-leilao');
    $('html, body').stop().animate({
     'scrollTop': $(value).offset().top
	}, 900);
    
  });

});

//create pagination
var paginationEl = $("ul.pagination");
if (paginationEl !== undefined) {
  var smallPagination = paginationEl.clone();
  smallPagination.removeClass("pagination").addClass("micropagination");
  $tocPagPanel.append(smallPagination);
  $tocListPanel.css('margin-top','20px');
}