HyperWriteAI Right-Click Fix

Enables right-click functionality to open links in a new tab on HyperWriteAI Personal Assistant.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @namespace         https://greasyfork.org/zh-CN/users/106222-qxin-i
// @name              HyperWriteAI Right-Click Fix
// @author            kweenash
// @description       Enables right-click functionality to open links in a new tab on HyperWriteAI Personal Assistant.
// @version           1.2
// @license           MIT
// @match              https://app.hyperwriteai.com/personalassistant
// @grant              GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Add CSS to override right-click restrictions
    GM_addStyle(`
        body {
            -webkit-user-select: auto !important;
            -moz-user-select: auto !important;
            -ms-user-select: auto !important;
            user-select: auto !important;
        }
        a {
            cursor: pointer !important;
        }
    `);

    // Override right-click restrictions
    document.addEventListener('contextmenu', function(e) {
        e.preventDefault();
        // Get the link element
        const linkElement = e.target.closest('a');
        if (!linkElement) return;
        // Get the link URL
        const linkUrl = linkElement.href;
        // Open the link in a new tab
        chrome.tabs.create({ url: linkUrl, active: true });
    });
})();