您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Extending the keyboard shortcuts for the Fantia image slideshow interface
当前为
- // ==UserScript==
- // @name Fantia image slideshow keyboard shortcuts
- // @namespace http://rjhsiao.me/gmscripts
- // @version 1.0.0
- // @description Extending the keyboard shortcuts for the Fantia image slideshow interface
- // @author RJ Hsiao
- // @supportURL https://github.com/RJHsiao/fantia-image-slideshow-keyboard-shortcuts
- // @license gpl
- // @match https://fantia.jp/posts/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=fantia.jp
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Workaround: do not scroll up to page top when esc-key pressed on image slideshow showing
- document.addEventListener('keydown', ev => {
- if (document.getElementById('image-slideshow') && ev.key === 'Escape') {
- ev.preventDefault();
- ev.stopPropagation();
- return;
- }
- });
- document.addEventListener('keyup', ev => {
- if (ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey) {
- return;
- }
- let imgSS = document.getElementById('image-slideshow');
- if (!imgSS) {
- return;
- }
- switch (ev.key) {
- case 'ArrowLeft':
- imgSS.querySelector('a.move-button.prev.clickable')?.click()
- return;
- case 'ArrowRight':
- imgSS.querySelector('a.move-button.next.clickable')?.click()
- return;
- case 'Escape':
- imgSS.querySelector('a.btn.btn-dark.btn-sm > i.fa-close')?.click()
- return;
- }
- });
- console.log("Fantia image slideshow key binging loaded.");
- })();