Created
January 3, 2016 13:36
-
-
Save tiansh/7e5bd9d652896f8d3a79 to your computer and use it in GitHub Desktop.
【用户脚本】微博热键禁用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Weibo Disable Hotkeys | |
// @name:zh 微博热键禁用 | |
// @namespace https://github.com/tiansh/ | |
// @description 禁用微博的热键 | |
// @include http://www.weibo.com/* | |
// @include http://weibo.com/* | |
// @include http://d.weibo.com/* | |
// @include http://s.weibo.com/* | |
// @exclude http://weibo.com/a/bind/* | |
// @exclude http://weibo.com/nguide/* | |
// @exclude http://weibo.com/ | |
// @version 1.0 | |
// @author 田生 http://weibo.com/tsh90 | |
// @copyright 田生; The MIT License | |
// @license The MIT License (MIT); http://opensource.org/licenses/MIT | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
(function inject(content) { | |
window.eval('(' + content + '())'); | |
}(function disableHotkeys() { | |
var retry = function () { return setTimeout(disableHotkeys, 0); }; | |
if (!window.STK || !STK.namespace) return retry(); | |
STK.namespace('v6home', function (a) { | |
if (!a.hotKey || !a.lib || !a.lib.cite || !a.lib.cite.hotkey) return retry(); | |
var ori = a.hotKey.remove; | |
a.hotKey.remove = function whatthefuck(target, key, callback, config) { | |
if (config.type === ':') { | |
ori.apply(this, [ | |
target, | |
[key[0].split(':')[0]], | |
callback, | |
{ | |
type: key[0].split(':')[1], | |
disableInInput: config.disableInInput | |
} | |
]); | |
} else ori.apply(this, arguments); | |
}; | |
try { a.lib.cite.hotkey().destroy(); } catch (e) { } | |
a.hotKey.remove = ori; | |
a.lib.cite.hotkey = function () { | |
return { destroy: function () { } }; | |
}; | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment