|
那单独给抖音换一种写法吧:
- // ==UserScript==
- // @name Context menu key trigger
- // @version 0.2.0
- // @description Allow context menus to be triggered by a key press
- // @author dragonish
- // @namespace https://github.com/dragonish
- // @license GNU General Public License v3.0 or later
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function () {
- function inputHandler(ele) {
- ele.blur();
- const curEle = document.activeElement;
- document.body.addEventListener('click', () => {
- if (document.activeElement === curEle) {
- ele.focus();
- }
- }, {
- once: true
- });
- }
- document.querySelectorAll('input, textarea').forEach(ele => {
- ele.addEventListener('contextmenu', function () {
- inputHandler(this);
- });
- });
- if (location.href.includes('douyin.com')) {
- document.body.addEventListener('contextmenu', function (evt) {
- if (evt.target) {
- const ele = evt.target;
- if (ele.nodeName === 'INPUT') {
- inputHandler(ele);
- }
- }
- });
- }
- })();
复制代码 |
|