CA有一个website,它以某种非标准的方式禁用粘贴,因为用于纠正此行为的任何标准技术(在about:config for Firefox,extensions for Firefox或Chrome中设置正确的选项)都不起作用。当您尝试粘贴到其中一个不允许的字段时,它会弹出一个对话框,显示“对不起,此功能被禁用。”
发布于 2018-09-10 08:49:34
你可以在源代码中看到它是如何实现的--它们有一个内联的keydown
属性:
<input class="entry-field" name="usc.form.password.new.confirm" id="password_new_confirm" value="" size="20" maxlength="20" tabindex="3" onmousedown="whichButton(event, 'Sorry, this functionality is disabled.')" onkeydown="return noCTRL(event, 'Sorry, this functionality is disabled.')" type="password" />
一种选择是编写一个在捕获阶段拦截keydown
事件的用户脚本,并调用stopPropagation()
,这样事件就不会捕获到受限制字段(如“验证密码”和“电子邮件地址”字段)上的侦听器:
// ==UserScript==
// @name Reenable Paste
// @namespace CertainPerformance
// @version 1
// @match https://www.dmv.ca.gov/FIM/sps/uscfed/usc/self/account/create
// @grant none
// ==/UserScript==
document.body.addEventListener('keydown', (e) => {
e.stopPropagation();
}, true);
https://stackoverflow.com/questions/52249757
复制相似问题