数据酷客大数据综合实训平台解除复制限制

Allow copying text in specific section on specific website

// ==UserScript==
// @name         数据酷客大数据综合实训平台解除复制限制
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Allow copying text in specific section on specific website
// @author       Your Name
// @match        http://pm.cookdata.cn/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    var leftPart = document.querySelector('.left-part');
    if (leftPart) {
        
        leftPart.addEventListener('copy', (e) => {
            e.stopPropagation();
        }, true);
        leftPart.addEventListener('cut', (e) => {
            e.stopPropagation();
        }, true);
        leftPart.addEventListener('contextmenu', (e) => {
            e.stopPropagation();
        }, true);
        leftPart.addEventListener('selectstart', (e) => {
            e.stopPropagation();
        }, true);
        leftPart.addEventListener('mousedown', (e) => {
            e.stopPropagation();
        }, true);

        // 移除可能的禁用CSS样式
        const styles = document.createElement('style');
        styles.innerHTML = `
            .left-part * {
                -webkit-user-select: text !important;
                -moz-user-select: text !important;
                -ms-user-select: text !important;
                user-select: text !important;
            }
        `;
        document.head.appendChild(styles);

        const eventTypes = ['copy', 'cut', 'contextmenu', 'selectstart', 'mousedown'];
        eventTypes.forEach((eventType) => {
            leftPart.addEventListener(eventType, (event) => {
                event.stopImmediatePropagation();
            }, true);
        });
    }

})();