HyperWriteAI Right-Click Fix

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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 });
    });
})();