0% found this document useful (0 votes)
4 views4 pages

User Script

This document is a user script designed for the Zhihuishu platform to automate answering habit score questions. It utilizes JavaScript to interact with the webpage, generate responses based on user input, and track answered questions. The script includes features for rendering buttons for different response types and managing user answers through local storage.

Uploaded by

coltanige
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

User Script

This document is a user script designed for the Zhihuishu platform to automate answering habit score questions. It utilizes JavaScript to interact with the webpage, generate responses based on user input, and track answered questions. The script includes features for rendering buttons for different response types and managing user answers through local storage.

Uploaded by

coltanige
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

"// ==UserScript==

// @name Whee1-智慧树(知到)习惯分问答垃圾话生成器(停止维护)
// @namespace [Link]
// @version 1.1.6
// @description 半自动回答习惯分问题
// @author ch3cknull
// @require [Link]
// @match [Link]
// @license MIT
// ==/UserScript==
(function() {
const e = [Link]("MouseEvents");
[Link]("click", true, true);
const input = [Link]("HTMLEvents");
[Link]("input", true, false);
const state = ([Link]('home'))?'home':'detail'
const MY_ANSWER_API =
"[Link]
const HOT_QUESTION =
"[Link]
const NEW_QUESTION =
"[Link]
const config = {
offset: 0,
currURL: HOT_QUESTION
}
const CASLOGC = [Link](';')
.filter(item => [Link]('CASLOGC'))
.toString().trim()
.replace(/\"/g, "'").split('=')[1]
const uuid = [Link](decodeURIComponent(CASLOGC)).uuid
let reqCount = 0
let params = {
uuid: uuid, dateFormate: new Date() * 1,
pageIndex: 0, pageSize: 50
}
[Link] = [Link]('?')[1].split('&')
.filter( item => [Link]('recruitId'))[0].split('=')[1]
[Link] = [Link]('/')[6].split('?')[0]

function Grama(mode) {
const question = [Link]('.question-
content').children[0].innerText
const ans = [Link](/\?|。|!|!|?|\.|{是|对}{吗|嘛|么}|什么|/g, "").replace(/嘛|
吗|么/g, '')
.replace(/是{否|不是}/g, '是').replace(/你们|你/g, '我').replace(/有没有/, '有').replace(/
能不能/,'能')
.replace(/[\(|(][\u4E00-\u9FA5A-Za-z0-9_]+[\)|)]/g, '')
const answer = {
positive: [
`你好,我认为${ans}`,
`是的,${ans}`,
],
negative: [
`不对,${ans}是不对的`
],
nonsence: [
`我们需要辩证看待,有些是好的,有些是不好的`,
`这不是绝对的,我们要理性看待`,
`没有绝对是好的,还是坏的`
]
}
let arr = [Link](answer).flat()
if ([Link](answer).includes(mode)) arr = answer[mode]
return arr[ parseInt([Link]() * 100) % [Link]] + "。"
}

function Render() {
return `<div class=wheel-pannel><button class="wheel-button wheel-positive">是的<
/button><button class="wheel-button wheel-negative">不是</button><button
class="wheel-button wheel-nonsence">中立</button></div><style>.wheel-
pannel{position:fixed;right:300px;top:120px;width:80px;height:30px;z-
index:3000}.wheel-button{margin:5px 0;padding:0
5px;height:30px;width:80px;border:0;outline:0;border-radius:8px;color:#f0f8ff;font-
size:16px;letter-spacing:1px}.wheel-positive{background:#7fd826}.wheel-
negative{background:#d82626}.wheel-positive:hover{background:#99e051}.wheel-
negative:hover{background:#e05151}.wheel-nonsence{background:black}.wheel-
nonsence:hover{background:#333333}</style>`
}

function binding() {
const panel = [Link]('.wheel-pannel')
if (!panel) [Link]('not panel')
[Link]('.wheel-pannel').addEventListener('click', (e) => {
const text = [Link]('textarea')
const mode = [Link][1].split('wheel-')[1]
[Link] = Grama(mode)
[Link](input)
})
[Link]('.up-btn').addEventListener('click', () => {
const questionId = [Link]('/')[4].split('?')[0]
let answered = getMyAnswer()
[Link](questionId)
[Link]('answered', [Link](answered))
})
}

function bindingHome() {
let list = [Link]('.el-scrollbar__view').children[0]
[Link]('.tab-container').addEventListener('click', (e) => {
let text = [Link]
if (text == "热门") [Link] = HOT_QUESTION
if (text == "最新") [Link] = NEW_QUESTION
if (text == "热门" || text == "最新") diffImprove([Link])
})
let observer = new MutationObserver( mutations => {
[Link]( mutation => {
if ([Link] === 'childList') {
reqCount++;
if (reqCount == 50 && [Link] !== 51) {
diffImprove([Link])
}
}
})
})
[Link](list, {
attributes:false,
childList: true,
subtree:false,
})
}
async function getMyAnswer() {
const courseId = [Link]('/')[6].split('?')[0]
let answered = [Link]([Link]('answered')) || {}
let currentCourse = answered[courseId] || null
let lastModified = [Link]([Link]('lastModified')) || new
Date() * 1
let current = new Date() * 1
if (currentCourse == null || current - lastModified > 600*1000) {
const data = [Link](params)
[Link] = 200
await [Link](MY_ANSWER_API, {params:data}).then( res => {
currentCourse = [Link](item => [Link])
[Link](currentCourse)
answered[courseId] = currentCourse
[Link](currentCourse);
[Link]('answered', [Link](answered))
[Link]('lastModified', [Link](new Date()*1))
})
}
return answered[courseId]
}

async function diffImprove(url=HOT_QUESTION, offset=0) {


if ([Link]('home')) return
let myAnswer, pageAnswer, arr, ans
//params and offset
const data = [Link](params)
[Link] = [Link]
[Link] = [Link] + offset
// get data
myAnswer = await getMyAnswer()
await [Link](url, {params: data}).then( res => {
pageAnswer = [Link]
arr = [Link](item => [Link])
.filter(item => [Link](item))
ans = [Link]( item => [Link]([Link]))
.map(item => `${[Link]}${[Link]}`)
patchImprove(ans)
})
}
async function patchImprove(res) {
// iterate dom list and add marks
const list = [Link]([Link]('.question-item'))
[Link]( item => {
const flag = [Link]('.user-name').title +
[Link]('.question-content').title
if ([Link](flag)) {
const child = [Link](".question-content")
[Link] += "(已作答)"
[Link] = 'red'
reqCount = 0
}
})
}
[Link] = () => {
if (state == 'home') setTimeout(home, 1000)
else setTimeout(detail, 1000)

async function detail() {


const btn = [Link]('.my-answer-btn')
if (btn == null) return
[Link](e)
setTimeout(() => {
const text = [Link]('textarea')
const dialog = [Link]('.header-title')
if (!text) return
[Link] = Grama("default")
[Link](input)
[Link] += Render()
binding()
}, 200)
}
async function home() {
bindingHome()
diffImprove()
}
}
})();"

You might also like