lagou

在页面左下角添加按钮,点击按钮执行指定代码

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         lagou
// @namespace    your-namespace
// @version      1.0
// @description  在页面左下角添加按钮,点击按钮执行指定代码
// @author       Your Name
// @match        https://www.lagou.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 创建一个鼠标点击事件
    var event = new MouseEvent('click', {
        bubbles: true,
        cancelable: true,
        view: window
    });

    // 创建按钮元素
    var button = document.createElement('button');
    button.innerHTML = '执行操作'; // 按钮文本
    button.style.position = 'fixed';
    button.style.bottom = '10px'; // 距离底部的距离
    button.style.left = '10px'; // 距离左侧的距离
    button.style.zIndex = '9999';

    // 将按钮添加到页面中
    document.body.appendChild(button);

    // 绑定按钮点击事件
    button.addEventListener('click', function() {
        var first = document.querySelector(`#s_position_list > ul > li.con_list_item.first_row.default_list > div.list_item_top > div.position > div.p_top > a > h3`);
        first.dispatchEvent(event);
        for (let i = 2; i <= 15; i++) {
            // 窗口打开链接
            setTimeout(function() {
                var element = document.querySelector(`#s_position_list > ul > li:nth-child(${i}) > div.list_item_top > div.position > div.p_top > a > h3`);
                var innerEvent = new MouseEvent('click', {
                    bubbles: true,
                    cancelable: true,
                    view: window
                });
                // 触发点击事件
                element.dispatchEvent(innerEvent);
            },1000);
        }
    });
})();