Greasy Fork is available in English.
In search result, change page by keyboard. [a / ←]:prev page, [d / →]:next page. Search products in Ruten as default (exclude ebay, Rakuten).
当前为
// ==UserScript==
// @name Ruten - navigate by keyboard
// @name:zh-TW 露天拍賣 鍵盤導覽
// @description In search result, change page by keyboard. [a / ←]:prev page, [d / →]:next page. Search products in Ruten as default (exclude ebay, Rakuten).
// @description:zh-TW 搜尋結果用鍵盤翻頁,[a / ←]前一頁,[d / →]下一頁。搜尋時預設只找露天站內商品(排除 ebay, 樂天)
// @namespace http://greasyfork.icu/zh-TW/users/393133-evan-tseng
// @version 0.3
// @author Evan Tseng
// @match *.ruten.com.tw/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var fnKey = { shift: false, ctrl:false, alt:false, meta:false };
window.onfocus = function() { fnKey.shift = fnKey.ctrl = fnKey.alt = fnKey.meta = false; }
document.addEventListener("keyup", function(e) {
e = e || window.event;
switch(e.which || e.keyCode) {
case 16: // shift
fnKey.shift = false;
break;
case 17: // ctrl
fnKey.ctrl = false;
break;
case 18: // alt
fnKey.alt = false;
break;
case 91: // left Meta
case 93: // right Meta
fnKey.meta = false;
break;
}
});
document.addEventListener("keydown", async function(e) {
if(document.querySelector("input:focus, textarea:focus") || (fnKey.shift | fnKey.ctrl | fnKey.alt | fnKey.meta)) return;
e = e || window.event;
try{
switch(e.which || e.keyCode) {
case 16: // shift
fnKey.shift = true;
break;
case 17: // ctrl
fnKey.ctrl = true;
break;
case 18: // alt
fnKey.alt = true;
break;
case 91: // left Meta
case 93: // right Meta
fnKey.meta = true;
break;
case 39: // right
case 68: // 'd'
document.querySelector(".ui-search .Ct .pagination .next, .ui-seller .Ct .pagination li.next a, .rt-store-pagination li.next>a, .rt-jqmodal-panel .img-popup-content .rti-chevron-right-default").click();
break;
case 37: // left
case 65: // 'a'
document.querySelector(".ui-search .Ct .pagination .prev, .ui-seller .Ct .pagination li.prev a, .rt-store-pagination li.prev>a, .rt-jqmodal-panel .img-popup-content .rti-chevron-left-default").click();
break;
case 38: // up
case 87: // 'w'
document.querySelector(".item-gallery-main-image img.js-main-img").click();
break;
case 13: // enter
case 27: // esc
document.querySelector(".rt-jqmodal-jqmClose").click();
}
} catch(e){}
});
if(window.location.href.indexOf('//find.ruten.com.tw/s/?')>0) {
var watchElm=null;
const watchOpt = { 'attributes': true },
redir = function(){
if(window.location.href.search(/(area=|platform=)/)==-1){
window.location.href=window.location.href+"&platform=ruten";
}
},
observer = new MutationObserver(redir);
redir();
let waitt=window.setInterval(function(){
if(watchElm=document.querySelector("#ProdGridContainer")){
observer.observe(watchElm, watchOpt);
clearInterval(waitt);
}
},500);
}
})();