简体   繁体   English

保持与 Tampermonkey designMode 的活动链接?

[英]Maintain active links with Tampermonkey designMode on?

I created a script at Tampermonkey, where I can change any website.我在 Tampermonkey 创建了一个脚本,我可以在其中更改任何网站。

This is my script:这是我的脚本:

    // ==UserScript==
// @name         Edit any Website
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match      *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    // javascript:document.body.contentEditable = 'true' ;
    document.designMode='on' ;
    void 0
})();

But my problem is, when I click on hyperlinks/links, nothing happens, but the input field appears (which is actually the point of this script), but I want the input field to appear only when I don't click on links (so it should be normal to open the links I click on).但我的问题是,当我点击超链接/链接时,什么也没有发生,但输入字段出现(这实际上是这个脚本的重点),但我希望输入字段仅在我不点击链接时出现(所以打开我点击的链接应该是正常的)。 Is that possible and can someone help me how to adjust it?这可能吗?有人可以帮我调整一下吗?

U already tried something like this?你已经尝试过这样的事情吗?

    // ==UserScript==
// @name         Edit any Website
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match      *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    // javascript:document.body.contentEditable = 'true' ;
    document.designMode = 'on';

    document.querySelectorAll('a').forEach((a) => {
        a.addEventListener('click', (e) => {
            location = e.currentTarget.href;
        })
    })
})();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM