mobile01 方向鍵導覽

用方向鍵 [← / a] 切換前一頁,[→ / d] 切換次一頁,[↓ / s] 退回外層分類。右上角加入 [我的文章] 連結。

Stan na 30-10-2019. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         mobile01 方向鍵導覽
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  用方向鍵 [← / a] 切換前一頁,[→ / d] 切換次一頁,[↓ / s] 退回外層分類。右上角加入 [我的文章] 連結。
// @author       Evan Tseng
// @match        www.mobile01.com/*
// @match        www.5i01.com/*
// @grant        none
// ==/UserScript==

(function() {
	'use strict';

	var	elm=null;

	document.addEventListener("keydown", function(e) {
		if(document.querySelector(":focus")) return;
		e = e || window.event;
		try{
			switch(e.which || e.keyCode) {
				case 40: // down
				case 83: // 's'
					if(window.location.href.match(/\/topicdetail\.php\?/i))
						document.querySelector(".c-breadCrumb__item:last-child a").click();
					else
						document.querySelector(".c-breadCrumb__item:nth-last-of-type(-n+2) a").click();
					break;
				case 65: // 'a'
				case 37: // left
					document.querySelector(".l-pagination__page.is-active").previousSibling.firstChild.click();
					break;
				case 68: // 'd'
				case 39: // right
					document.querySelector(".l-pagination__page.is-active").nextSibling.firstChild.click();
					break;
			}
		} catch(e){}
	});

	// 登入後,畫面右上角顯示[我的文章]連結
	if(elm=document.querySelector(".l-signedIn")){
		var css='._myArticle{display:inline-block;white-space:nowrap;height:1em;font-size:calc(9pt + .25vw);text-align:center;padding:.3em;line-height:1;margin:calc(.6em - .38vw) 0 0 1mm;color:#ebeae7;background:#3a5;border-radius:5pt;box-shadow:inset 0 0 0 1px #3a5,inset 0 0 0 2px #ebeae7;transition:.2s}._myArticle:hover{color:#fff;background:#284;box-shadow:inset 0 0 0 1px #3a5,inset 0 0 0 2px #fff;}._myArticle:active{color:#ddd;background:#284;box-shadow:inset 0 0 0 1px #3a5,inset 0 0 0 2px #ddd;transition:.1s}',
			cssStyle=document.createElement('style');
		if(cssStyle.styleSheet) cssStyle.styleSheet.cssText=css;
		else cssStyle.appendChild(document.createTextNode(css));
		document.querySelector('head').appendChild(cssStyle);

		var myArticle=document.createElement('a');
		myArticle.setAttribute("href","/participatetopics.php");
		myArticle.setAttribute("class","_myArticle");
		myArticle.setAttribute("title","我的文章");
		myArticle.innerText="我的文章";
		elm.appendChild(myArticle);
	}

	// 移除指向本頁的連結
	elm=document.querySelectorAll(".l-pagination__page.is-active>a, .c-filter a.c-iconLink--gn");
	for(let i in elm) if(elm[i].tagName=="A") elm[i].removeAttribute("href");

})();