Greasy Fork

Greasy Fork is available in English.

涵创知产辅助脚本

本脚本简化了商标、专利等知识产权工作者日常业务的某些繁琐步骤,如删除了商标首页的5秒协议、专利办理系统首页的常用模块补充、专利电子发文电子客户端自动查询、河南政务服务网的法人、个人账户密码输入框反粘贴限制等

当前为 2024-08-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         涵创知产辅助脚本
// @namespace    http://tampermonkey.net/
// @version      2024-07-31
// @description  本脚本简化了商标、专利等知识产权工作者日常业务的某些繁琐步骤,如删除了商标首页的5秒协议、专利办理系统首页的常用模块补充、专利电子发文电子客户端自动查询、河南政务服务网的法人、个人账户密码输入框反粘贴限制等
// @author       HeNanHanChuang
// @match        https://cponline.cnipa.gov.cn/*
// @match        https://wssq.sbj.cnipa.gov.cn:9443/tmsve/wssqsy_getCayzDl.xhtml
// @match        https://interactive.cponline.cnipa.gov.cn/public-app-zxsq-guojia/chaxuntjmk/chaxun/dianzifwcx
// @match        https://login.hnzwfw.gov.cn/tacs-uc/login/index?refer=cp&backUrl=http://id.hnkjt.gov.cn/puias/login?to=http://qyyf.hnkjt.gov.cn/czbt//cz/ssologin
// @icon         https://i.postimg.cc/hG1CpFfb/LOGO.png
// @grant        none
// @license      MIT Festival Variant
// ==/UserScript==

(function() {
    'use strict';
    // 获取当前页面的URL
    const url = window.location.href;


    // 专利首页的脚本代码
    if (/https:\/\/cponline\.cnipa\.gov\.cn\/.*/.test(url)) {
        // 添加新的 span 元素的函数
        function addLinks() {
            const headerMenu = document.querySelector('.bl-header-menu');
            if (headerMenu && !headerMenu.dataset.linksAdded) {
                headerMenu.dataset.linksAdded = 'true';

                const links = [
                    { href: "https://interactive.cponline.cnipa.gov.cn/public-app-zxsq-guojia/chaxuntjmk/chaxun/dianzifwcx", text: "电子发文查询" },
                    { href: "https://cpquery.cponline.cnipa.gov.cn/chinesepatent/index", text: "专利费用查询" },
                    { href: "https://interactive.cponline.cnipa.gov.cn/public-app-zlswfw/feijianbeian/feijianbaggcx", text: "费减备案" }
                ];

                links.forEach(link => {
                    const newSpan = document.createElement('span');
                    newSpan.classList.add('custom-link'); // 添加自定义类名
                    const newAnchor = document.createElement('a');
                    newAnchor.href = link.href;
                    newAnchor.textContent = link.text;
                    newSpan.appendChild(newAnchor);
                    headerMenu.appendChild(newSpan);
                });
            }
        }

        // 添加 CSS 样式以确保元素不会换行并具有适当的间距
        function addStyles() {
            const style = document.createElement('style');
            style.textContent = `
            .bl-header-menu {
                display: flex;
                flex-wrap: nowrap;
                align-items: center;
            }
            .bl-header-menu span {
                margin-right: 15px; /* 根据需要调整间距 */
                font-size: 150%;
                font-weight: bold;
                align-items: center;
                font-family: 'LiSu', sans-serif; /* 设置字体为仿宋 */
            }
            .bl-header-menu span:last-child {
                margin-right: 0; /* 去除最后一个 span 的右边距 */
            }
        `;
            document.head.appendChild(style);
        }

        // 初始化脚本
        function init() {
            addStyles();
            setTimeout(addLinks, 0);
        }

        window.onload = init;
    }
    //商标主页屏蔽协议的脚本代码
    else if (url.includes("https://wssq.sbj.cnipa.gov.cn:9443/tmsve/wssqsy_getCayzDl.xhtml")) {
        // 定义一个函数,用于删除指定类名的元素
        function removeElementsByClass(className) {
            const elements = document.getElementsByClassName(className);
            while(elements.length > 0) {
                elements[0].parentNode.removeChild(elements[0]);
            }
        }

        // 等待页面完全加载后执行
        window.onload = function() {
            removeElementsByClass('bgPop'); // 删除类名为"bgPop"的元素
            removeElementsByClass("pop");   // 删除类名为"pop"的元素
        };
    }
    //专利电子发文自动查询
    else if (window.location.href.includes("https://interactive.cponline.cnipa.gov.cn/public-app-zxsq-guojia/chaxuntjmk/chaxun/dianzifwcx")) {
        // 定义一个函数,用于检查目标元素是否存在并点击
        function checkForTargetElement() {
            // 查找所有包含指定文本的<span>标签
            var spans = document.querySelectorAll('span');

            for (var span of spans) {
                // 检查<span>的文本内容
                if (span.textContent.trim() === '电子申请客户端') {
                    // 获取该<span>标签的父元素<li>
                    var li = span.closest('li');

                    if (li) {
                        // 触发<li>的点击事件
                        li.click();

                        // 定义一个函数,用于检查查询按钮
                        function checkForSearchButton() {
                            // 查找所有包含指定文本的<span>标签
                            var buttonSpans = document.querySelectorAll('span');

                            for (var buttonSpan of buttonSpans) {
                                // 检查<span>的文本内容
                                if (buttonSpan.textContent.trim() === '查询') {
                                    // 获取该<span>标签的父元素<button>
                                    var button = buttonSpan.closest('button');

                                    if (button) {
                                        // 触发<button>的点击事件
                                        button.click();
                                        return true; // 目标按钮找到并点击后,返回true
                                    }
                                }
                            }

                            return false; // 目标按钮未找到,返回false
                        }

                        // 使用setInterval定期检查页面内容
                        var buttonIntervalId = setInterval(function() {
                            if (checkForSearchButton()) {
                                // 如果找到并点击了目标按钮,清除定时器
                                clearInterval(buttonIntervalId);
                            }
                        }, 500); // 每500毫秒检查一次

                        return true; // 目标<li>元素找到并点击后,返回true
                    }
                }
            }

            return false; // 目标<li>元素未找到,返回false
        }

        // 使用setInterval定期检查页面内容
        var intervalId = setInterval(function() {
            if (checkForTargetElement()) {
                // 如果找到并点击了目标元素,清除定时器
                clearInterval(intervalId);
            }
        }, 500); // 每500毫秒检查一次
    }
    //河南政务服务网--启用密码输入框的粘贴功能
    else if (window.location.href.includes("https://login.hnzwfw.gov.cn/tacs-uc/login/index?refer=cp&backUrl=http://id.hnkjt.gov.cn/puias/login?to=http://qyyf.hnkjt.gov.cn/czbt//cz/ssologin")) {
   window.addEventListener('load', function() {
        var passwordField = document.getElementById('legalLoginPwd');
        if (passwordField) {
            passwordField.onpaste = null;
            console.log('为法人密码输入框启用了粘贴.');
        } else {
            console.log('没有找到密码字段');
        }

       var userPwd = document.getElementsByName('userPwd');

        if (userPwd[0]) {
            userPwd[0].onpaste = null;
            console.log('为个人用户密码输入框启用了粘贴.');
        } else {
            console.log('没有找到密码字段');
        }
    });
    }

})();