Backspace goes back

Backspace key = "go back" as it was before Chrome 52

目前为 2016-05-21 提交的版本。查看 最新版本

// ==UserScript==
// @name          Backspace goes back
// @include       *
// @description   Backspace key = "go back" as it was before Chrome 52
// @version       1.0
// @author        wOxxOm
// @namespace     wOxxOm.scripts
// @license       MIT License
// @run-at        document-start
// ==/UserScript==

document.addEventListener('keyup', goBack);
function goBack(e) {
	var el = document.activeElement;
	if (e.keyCode != 8 || e.altKey || e.shiftKey || e.metaKey || e.ctrlKey ||
		el && (el.isContentEditable ||
	           el.localName == 'input' && el.type.match(/^(text|color|date*|email|month|number|password|range|search|tel|time|url|week)$/) ||
	           el.localName == 'textarea'
			  )
	) {
		return;
	}
	history.back();
}