Greasy Fork

Greasy Fork is available in English.

EasyWJX

在问卷星的题目旁添加一个按钮以方便直接搜索内容

当前为 2022-09-25 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         EasyWJX
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  在问卷星的题目旁添加一个按钮以方便直接搜索内容
// @author       MelonFish
// @match        https://ks.wjx.top/*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @require      https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @require      https://www.layuicdn.com/layer/layer.js
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    console.log("EasyWJX is running. From xq.kzw.ink. Version 0.1")
    foreach();
    deleteAllCookies();
    if ($("#divTip").text().indexOf("最大填写次数")>=0) {
        alert('监测到您可能被问卷星限制,这种情况请清空浏览器Cookie并重新联网(开一下飞行模式)再试')
    }

    $('#spanPower').html('<a href="https://xq.kzw.ink" title="线圈_专为学生谋福利">线圈脚本</a><span>提供破解</span>')
    // 判断是否直接修改成绩
    if ($(".score-font-style").length>0) {
        var r=confirm("是否需要修改成绩?(可能出现问题,如修改效果不符合要求请刷新)")
        if (r==true)
        {
            var score=prompt("修改后的分数(注意不要大于总分)")
            if (score!=null && score!="")
            {
                $(".score-font-style").eq(0).text(score)
            }
            var correct_num=prompt("修改后的正确题数(注意不要大于总题数)")
            if (correct_num!=null && correct_num!="")
            {
                //$(".tbottom-title").eq(3).html('<span style="font-size:20px;">'+correct_num+'</span>')
                //$("span[style$='font-size:20px;']").text(correct_num)
                $(".score-form__list.clearfix .tht-content span").text(correct_num)
            }
        }
    }

    // 使用搜索的方式
    var div_list = $(".field-label");
    var btn_list = [];
    // var btn = $('<button type="button" style="height: 1.5rem; width: 2.3rem; margin-left: 1rem;" onclick="alert(102210);">搜索</button>')
    for (var i=0; i<div_list.length; i++) {
        var btn = document.createElement("button"); //创建一个input对象(提示框按钮)
        btn.id = "search_btn_"+i;
        btn.textContent = "搜索";
        btn.style.width = "2.3rem";
        btn.style.height = "1.5rem";
        btn.style.marginLeft = "1rem";
        btn.type = 'button';
        //绑定按键点击功能
        btn_list.push(btn)
        console.log(btn)
        btn.onclick = function (e){
            console.log('点击了按键', e.srcElement.id);
            var btn_num = parseInt(e.srcElement.id.split('_')[2]);
            var url = window.location.href;
            var search_content = div_list.eq(btn_num).text().replace('搜索', '').replace('复制','').replace('✅','');
            console.log(btn_num, search_content)
            //iframe 层
            /*
            layer.msg('hello');
            layer.open({
                type: 2,
                title: '很多时候,我们想最大化看,比如像这个页面。',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['100%', '100%'],
                content: 'https://www.wjx.cn/',
                zIndex: layer.zIndex, //重点1
                success: function(layero){
                    layer.setTop(layero); //重点2
                }
            });
            */

            //window.open('https://www.bing.com/search?q='+search_content)
            if (e.srcElement.textContent=="搜索") {
                var iframe = document.createElement("iframe");
                iframe.id = "search_iframe"+btn_num;
                iframe.style.width = "100%";
                iframe.style.height = "20rem";
                iframe.style.marginTop = "2rem";
                iframe.src = 'https://www.bing.com/search?q='+search_content
                div_list.eq(btn_num).append(iframe)
                e.srcElement.textContent="收起";
            } else {
                e.srcElement.textContent="搜索";
                document.getElementById("search_iframe"+btn_num).remove();
            }
        };
        div_list.eq(i).append(btn)
    }
    for (var j=0; j<div_list.length; j++) {
        var copy_btn = document.createElement("button"); //创建一个input对象(提示框按钮)
        copy_btn.id = "copy_btn_"+j;
        copy_btn.textContent = "复制";
        copy_btn.style.width = "2.3rem";
        copy_btn.style.height = "1.5rem";
        copy_btn.style.marginLeft = "1rem";
        copy_btn.type = 'button';
        copy_btn.onclick = function (e){
            console.log('点击了按键', e.srcElement.id);
            var btn_num = parseInt(e.srcElement.id.split('_')[2]);
            var search_content = div_list.eq(btn_num).text().replace('搜索', '').replace('复制','').replace('✅','');
            copy_to_clipboard(search_content)
            e.srcElement.textContent ="✅";
            setTimeout(function(){
                e.srcElement.textContent="复制";
            },2000)
        };
        div_list.eq(j).append(copy_btn)
    }


    function copy_to_clipboard(txt_str){
        const input = document.createElement('input');
        document.body.appendChild(input);
        input.setAttribute('value', txt_str);
        input.select();
        if (document.execCommand('copy')) {
            document.execCommand('copy');
            console.log('复制成功');
            //Alert(500,'复制成功');
        }
        document.body.removeChild(input);
    }
    function deleteAllCookies() {
        var cookies = document.cookie.split(";");
        console.log(cookies)
        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 +"=;";
            //document.cookie = null
        }
        var cookies2 = document.cookie.split(";");
        console.log(cookies2)
    }
    function DelCookie(name) {
        var exp = new Date();
        exp.setTime (exp.getTime() - 1);
        var cval = GetCookie (name);
        document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
    }
    function foreach() {
        var strCookie=document.cookie;
        var arrCookie=strCookie.split("; "); // 将多cookie切割为多个名/值对
        for(var i=0;i <arrCookie.length;i++)
        { // 遍历cookie数组,处理每个cookie对
            var arr=arrCookie[i].split("=");
            if(arr.length>0)
                DelCookie(arr[0]);
        }
    }
    function GetCookie(name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen)
        {
            var j = i + alen;
            if (document.cookie.substring(i, j) == arg)
                return GetCooki (j);
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) break;
        }
        return null;
    }
    function GetCooki(offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
            endstr = document.cookie.length;
        return decodeURIComponent(document.cookie.substring(offset, endstr));
    }

})();