Skip to content

Instantly share code, notes, and snippets.

@tiansh
Created January 3, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiansh/7e5bd9d652896f8d3a79 to your computer and use it in GitHub Desktop.
Save tiansh/7e5bd9d652896f8d3a79 to your computer and use it in GitHub Desktop.
【用户脚本】微博热键禁用
// ==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