您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Keyboard shortcuts for the Geek
当前为
- // ==UserScript==
- // @name BGG Shortcuts
- // @namespace BGG Shortcuts
- // @version 0.7.0
- // @description Keyboard shortcuts for the Geek
- // @include http://*.boardgamegeek.*/*
- // @include http://boardgamegeek.*/*
- // @copyright 2013+, JB McMichael
- // ==/UserScript==
- /*
- * CHANGLOG::
- * ============================================
- * 0.7.0 - Changed the links to just be J for next item, H for home, and / for search, but disabled shortcuts in form elements
- * 0.6.1 - Give the page some time to load its scripts before changing links
- * 0.6 - Added a shortcut to go to the searchbox Ctrl + /
- * 0.5 - Added homepage links opening in new tab
- * 0.4 - If search returns one result just go to that result
- * 0.3 - Added homepage shortcut; Ctrl + Shift + H
- * 0.2 - Cleaned up the subscription jump link
- * 0.1 - First version, shortcut for subscriptions; Ctrl + M
- *
- */
- (function () {
- "use strict";
- console.log('Loaded BGG Shortcuts');
- document.body.addEventListener('keydown', function(e) {
- var active = document.activeElement.tagName.toLowerCase(),
- badElements = ['input', 'textarea', 'select'];
- // ignore shortcuts if we are in some form of input
- if (badElements.indexOf(active) === -1) {
- // Next subscription item J
- if (e.keyCode === 74) {
- [].slice.call(document.querySelectorAll("img:not(dn).nextsubcol"))[0].parentNode.parentNode.click();
- }
- // Home page H
- if (e.keyCode === 72 && window.location.href !== window.location.origin) {
- window.location.href = window.location.origin;
- }
- // Search box jump /
- if (e.keyCode === 191) {
- var searchbox = document.getElementById('sitesearch');
- document.body.scrollTop = 0;
- searchbox.focus();
- window.setTimeout(function() { searchbox.value = ''; }, 10);
- }
- }
- }, false);
- //check for one result on the search page
- if (window.location.pathname === '/geeksearch.php' && window.location.search.search(/action=search/)) {
- var results = document.querySelectorAll('#collectionitems tbody tr');
- console.log('We are searching');
- if (results.length === 2) {
- console.log('Found just one result, redirect');
- var link = results[1].querySelectorAll('#results_objectname1 a'),
- href = link[0].getAttribute('href');
- window.location.href = window.location.origin + href;
- }
- }
- // set all homepage module links to open in new tab
- if (window.location.pathname === '/') {
- window.setTimeout(function(){
- console.log('Changing homepage links');
- var links = document.querySelectorAll('.innermoduletable tbody td a.ng-binding'),
- linkArray = [].slice.call(links);
- linkArray.forEach(function(item, index){
- item.setAttribute('target', '_blank');
- });
- },500);
- }
- }());