Geeklist Tweaks

Various tweaks to improve BGG.

当前为 2016-09-01 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name       Geeklist Tweaks
// @namespace  tequila_j-script
// @version    0.2.0
// @description  Various tweaks to improve BGG. 
// 
// @match      https://boardgamegeek.com/geeklist/*
// @match      https://www.boardgamegeek.com/geeklist/*
// @match      http://boardgamegeek.com/geeklist/*
// @match      http://www.boardgamegeek.com/geeklist/*
// 
// @require	http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant    GM_addStyle
// ==/UserScript==

  
GM_addStyle("\
div.t-nav-container {\
	position: absolute;\
	top: 0px;\
	right: -35px;\
    background-color: rgba(200,200,255,0.4);\
    border-radius: 5px;\
    //opacity: 0.5;\
	width: 30px;\
	height: 50px;\
	text-align: center;\
	padding: 5px 0px;\
}\
div.t-nav-container:hover {\
    opacity: 0.95;\
}\
div.t-nav-container i.fa {\
	font-size: 20px;\
	padding: 3px 0px;\
	cursor: pointer;\
}\
\
");
            
$(document).ready(function() {
   'use strict';
    /*jshint multistr: true */
  
  $("head").append (
    '<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">'
  );
  
  //lets find items, excluding multiple comments
  var newItems = [];
  
  var geekItems = $('div.mb5');
  
  for (var i=0; i < geekItems.length; i++)  {
    var thisGI = $(geekItems[i]);
    var newSI = thisGI.find('div.subbed_selected,div.subbed');
    var firstIsGeekItem = false;
    if (newSI.length > 0) {
      var el = newSI[0];
      newItems.push(newSI[0]);
      firstIsGeekItem = $(el).attr('data-objecttype') == "listitem";
    }
    if (newSI.length > 1 && firstIsGeekItem) {
      newItems.push(newSI[1])
    }
  }
  
//  console.log('New items in geeklists:' + newItems.length);
  
  //we will try to find comments at the end of the page also
  var pageComments = $('div.mb5:first').parent().children('div:not(.mb5)').find('div.comment_ctrl').find('div.subbed_selected,div.subbed');
  console.log(pageComments);
  if (pageComments.length > 0) {
    newItems.push(pageComments[0]);
//    console.log("New page comments also ");
  }
  
//  console.log("Size: " + newItems.length);
  
  var iconUp = $('<i class="fa fa-caret-square-o-up" aria-hidden="true"></i>');
  var iconDown = $('<i class="fa fa-caret-square-o-down" aria-hidden="true"></i>');
  var iconBox = $('<div class="t-nav-container"></div>');
  
  
  
  	$(newItems).each(function(index) {
    
    	var thisItem = $(this);
    
    	thisItem.css('position','relative');

    	var iconContainer = iconBox.clone();
    	thisItem.append(iconContainer);
    
    	//go up
    	if (index != 0) {
      		var upI = iconUp.clone();
    		upI.click(function () {
	      		$("html, body").animate({ scrollTop: $(newItems[index - 1]).offset().top }, "fast");
				return false;
	    	});
	      	iconContainer.append(upI);
	      	
	    } else {
	      iconContainer.append(iconDown.clone().css('visibility','hidden'));
	    }
    
	    //go down
	    if (index != newItems.length - 1) {
	      	var downI = iconDown.clone();
	    	downI.click(function () {
	      		$("html, body").animate({ scrollTop: $(newItems[index + 1]).offset().top }, "fast");
				return false;
	    	});
	        
	      	iconContainer.append(downI);
	    }
  
  	});
  

    
  
});