Go To Review

Adds a "G+R" shortcut to go to review

目前為 2015-03-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Go To Review
// @namespace  http://greasyfork.org
// @author         Cameron Bernhardt (AstroCB)
// @description  Adds a "G+R" shortcut to go to review
// @version       1.0
// @include        *://*.stackexchange.com/*
// @include        *://*stackoverflow.com/*
// @include        *://*serverfault.com/*
// @include        *://*superuser.com/*
// @include        *://*askubuntu.com/*
// @include        *://*stackapps.com/*
// ==/UserScript==

function listenForKeys(e) {
	if (e.keyCode === 114 && lastKey === 103) {
		$(".topbar-menu-links")[0].children[0].click();
	}
	lastKey = e.keyCode;
}

function stopListeningForKeys() {
	console.log("Body unbound");
	$("body").unbind("keypress", listenForKeys);
};

function attachListener() {
	console.log("Body bound");
	var lastKey;
	$("body").keypress(listenForKeys);
}

var main = function () {
	attachListener();

	$("input").focus(stopListeningForKeys);
	$("input").blur(attachListener);

	window.setInterval(function () { // Some text fields are created dynamically
		$("textarea").focus(stopListeningForKeys).keypress(stopListeningForKeys);
		$("textarea").blur(attachListener);
	}, 1000);
};

var listen = document.createElement("script");
listen.type = "text/javascript";
listen.textContent = listenForKeys.toString();
document.body.appendChild(listen);

var stop = document.createElement("script");
stop.type = "text/javascript";
stop.textContent = stopListeningForKeys.toString();
document.body.appendChild(stop);

var attach = document.createElement("script");
attach.type = "text/javascript";
attach.textContent = attachListener.toString();
document.body.appendChild(attach);

var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + main.toString() + ")();";
document.body.appendChild(script);