Greasy Fork

Greasy Fork is available in English.

问卷星_大塘卫生院专供

用于大塘卫生院问卷调查

当前为 2024-07-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         问卷星_大塘卫生院专供
// @namespace    https:www.yowayimono.cn
// @version      0.3
// @description  用于大塘卫生院问卷调查
// @author       Yowayimono
// @match        https://www.wjx.cn/*
// @grant        none
// @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
// ==/UserScript==

sessionStorage.clear();

(function() {
    'use strict';
    var url = "https://www.wjx.cn/vm/hS5amYI.aspx";
    if (window.location.href.includes("https://www.wjx.cn/wjx/join/complete")) {
        // alert("恭喜你!看起来你已经成功了\n可不要忘记给视频教程一个免费的赞喔 ~\n取消此提示请删除源码中的43行")
        window.location.href = url;
    }

    var socre = [9, 9.5, 8, 8.8, 7, 9.4, 8.5];
    var appraise = ["还不错,服务很好", "医生态度很好,服务也不错", "医院卫生不错", "药效很快,病好的很快", "医生很负责,态度很好"];

    function generateChinesePhoneNumbers(count) {
        const phoneNumbers = [];
        const prefixes = ['131', '132', '133', '134', '135', '136', '137', '138', '139', '147', '150', '151', '152', '153', '155', '156', '157', '158', '159', '166', '170', '171', '172', '173', '175', '176', '177', '178', '180', '181', '182', '183', '184', '185', '186', '187', '188', '189'];

        for (let i = 0; i < count; i++) {
            const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
            const suffix = Math.floor(Math.random() * 90000000) + 10000000; // 8 位随机数字
            const phoneNumber = prefix + suffix.toString();
            phoneNumbers.push(phoneNumber);
        }

        return phoneNumbers;
    }

    const phones = generateChinesePhoneNumbers(100);

    clearCookies();

    function getRandomNumber(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function clearCookies() {
        var cookies = document.cookie.split(";");
        for (var i = 0; i < cookies.length; i++) {
            var cookie = cookies[i];
            var eqPos = cookie.indexOf("=");
            var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
            document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;";
        }
    }

    function doNext() {
        var nextButton = document.getElementById("divNext").querySelector("a");
        nextButton.click();
    }

    doNext();

    function setRandomInputValue(inputId, valueArray) {
        var inputElement = document.getElementById(inputId);
        var randomIndex = getRandomNumber(0, valueArray.length - 2);
        inputElement.value = valueArray[randomIndex];
        console.log("设置的值:", valueArray[randomIndex]);
    }

    setRandomInputValue("q1", phones);

    doNext();

    clickLayButton();

    function clickRandomRadio(container) {
        var radioElements = container.getElementsByClassName("ui-radio");
        var randomIndex = getRandomNumber(0, radioElements.length - 1);
        radioElements[randomIndex].click();
    }

    function clickLayButton() {
        var lay = document.getElementsByClassName("layui-layer-btn0");
        if (lay.length > 0) {
            lay[0].click();
        }
    }

    function setInputValue(div, value) {
        var ins = div.querySelectorAll("input");
        if (ins.length > 0) {
            ins[0].value = value;
        }
    }

    var questions = document.getElementsByClassName("field ui-field-contain");

    clickRandomRadio(questions[1]);

    var labelDivs = questions[2].getElementsByClassName("ui-radio");
    for (var i = 0; i < labelDivs.length; i++) {
        var tmp = labelDivs[i];
        var d = tmp.getElementsByClassName("label")[0];
        var text = d.textContent.trim();
        if (text === "乡镇卫生院") {
            console.log(text);
            tmp.click();
            var labelDivs2 = questions[4].getElementsByClassName("ui-radio");
            labelDivs2[2].click();
        }
    }

    function setAge(div) {
        const ageInput = div.querySelectorAll("input");
        const randomAge = getRandomNumber(15, 70);
        ageInput[0].value = randomAge;
        console.log(`设置 ${div} 的年龄为 ${randomAge}`);
    }

    setAge(questions[6]);

    clickRandomRadio(questions[7]);
    clickRandomRadio(questions[8]);
    clickRandomRadio(questions[9]);
    clickRandomRadio(questions[10]);
    clickRandomRadio(questions[11]);
    clickRandomRadio(questions[12]);
    clickRandomRadio(questions[13]);

    var ins2 = questions[15].querySelectorAll("input");
    ins2[0].value = 9;
    setInputValue(questions[14], "9");
    setInputValue(questions[15], "挺不错的");

    // 从 localStorage 中获取提交次数
    let submissionCount = parseInt(localStorage.getItem('submissionCount')) || 0;

    // 创建一个显示提交次数的元素
    const submissionCountElement = document.createElement('div');
    submissionCountElement.style.position = 'fixed';
    submissionCountElement.style.top = '10px';
    submissionCountElement.style.left = '10px';
    submissionCountElement.style.backgroundColor = 'white';
    submissionCountElement.style.border = '1px solid black';
    submissionCountElement.style.padding = '5px';
    submissionCountElement.style.zIndex = '1000';
    submissionCountElement.textContent = `提交次数: ${submissionCount}`;
    document.body.appendChild(submissionCountElement);

    async function submit() {
        submissionCount++; // 每次提交时增加计数器
        localStorage.setItem('submissionCount', submissionCount); // 保存提交次数到 localStorage
        submissionCountElement.textContent = `提交次数: ${submissionCount}`; // 更新显示的提交次数

        await new Promise((resolve) => {
            setTimeout(() => {
                const nextBtn = document.evaluate('//*[@id="ctlNext"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
                if (nextBtn) {
                    nextBtn.click();
                    resolve();
                }
            }, 5000);
        });

        await new Promise((resolve) => {
            setTimeout(() => {
                document.querySelector('#rectMask').click();
                resolve();
            }, 2000);
        });

        await new Promise((resolve) => {
            setTimeout(() => {
                simulateSliderVerification();
                resolve();
            }, 4000);
        });

        await new Promise((resolve) => {
            setTimeout(() => {
                window.location.reload(); // 刷新页面
                resolve();
            }, 5000);
        });
    }

    async function simulateSliderVerification() {
        const slider = document.querySelector('#nc_1__scale_text > span');
        if (slider.textContent.startsWith('请按住滑块')) {
            const width = slider.offsetWidth;
            const eventOptions = { bubbles: true, cancelable: true };
            const dragStartEvent = new MouseEvent('mousedown', eventOptions);
            const dragEndEvent = new MouseEvent('mouseup', eventOptions);
            const steps = 10;
            const stepWidth = width / steps;
            let currX = stepWidth / 2;
            slider.dispatchEvent(dragStartEvent);
            const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
            for (let i = 0; i < steps; i++) {
                const randomTime = Math.random() * 100 + 50;
                slider.dispatchEvent(new MouseEvent('mousemove', Object.assign({ clientX: currX }, eventOptions)));
                currX += stepWidth;
                await delay(randomTime);
            }
            slider.dispatchEvent(dragEndEvent);
            console.log("滑动完成");
        }
    }

    const targetUrl = 'https://www.wjx.cn/wjx/join/completemobile2.aspx';

    window.addEventListener('load', function() {
        if (window.location.href.includes(targetUrl)) {
            captureScreenshot();
        }
    });

    function captureScreenshot() {
        html2canvas(document.body).then(function(canvas) {
            var dataURL = canvas.toDataURL('image/png');
            GM_download(dataURL, 'screenshot.png');
        });
    }

    // 确保每次提交时都调用 submit 函数
    setInterval(submit, 15000); // 每 15 秒提交一次
})();