Greasy Fork

Greasy Fork is available in English.

叔叔不约只配女-新版适配

叔叔不约只配女,适配新版UI

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         叔叔不约只配女-新版适配
// @namespace    yeyu
// @version      2.1
// @description  叔叔不约只配女,适配新版UI
// @author       夜雨
// @match        *://*.shushubuyue.net/*
// @match        *://*.shushubuyue.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=shushubuyue.net
// @license      MIT
// ==/UserScript==

(function() {

	var autoReply = '你好喔' // 这里填写匹配成功后,你要自动填充的句子
	var firstAuto = true

	console.log('========================================')
	console.log('叔叔不约脚本已启动 v2.0')
	console.log('========================================')

	// 强力点击函数
	function forceClick(elem) {
		if (!elem) return false
		console.log('点击:', (elem.innerText || '').substring(0, 20))
		elem.click()
		if (elem.parentElement) elem.parentElement.click()
		elem.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
		elem.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }))
		elem.dispatchEvent(new MouseEvent('click', { bubbles: true }))
		if (elem.parentElement) {
			elem.parentElement.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
			elem.parentElement.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }))
			elem.parentElement.dispatchEvent(new MouseEvent('click', { bubbles: true }))
		}
		try {
			elem.dispatchEvent(new TouchEvent('touchstart', { bubbles: true }))
			elem.dispatchEvent(new TouchEvent('touchend', { bubbles: true }))
			if (elem.parentElement) {
				elem.parentElement.dispatchEvent(new TouchEvent('touchstart', { bubbles: true }))
				elem.parentElement.dispatchEvent(new TouchEvent('touchend', { bubbles: true }))
			}
		} catch(e) {}
		return true
	}

	// 查找包含文字的元素
	function findByText(text, exact) {
		var all = document.querySelectorAll('*')
		for (var i = 0; i < all.length; i++) {
			var txt = (all[i].innerText || '').trim()
			if (exact) {
				if (txt === text) return all[i]
			} else {
				if (txt.indexOf(text) !== -1) return all[i]
			}
		}
		return null
	}

	// 获取性别信息
	function getGender() {
		var elem = findByText('对方信息')
		if (elem) {
			var text = elem.innerText || ''
			if (text.indexOf('男生') !== -1) return '男生'
			if (text.indexOf('女生') !== -1) return '女生'
		}
		return null
	}

	// 发送消息
	function sendMessage() {
		var textarea = document.querySelector('textarea')
		if (textarea) {
			console.log('✓ 找到输入框')
			textarea.value = autoReply
			textarea.dispatchEvent(new Event('input', { bubbles: true }))
			
			setTimeout(function() {
				var sendBtn = document.querySelector('.send-btn')
				if (sendBtn) {
					console.log('✓ 点击发送按钮')
					forceClick(sendBtn)
					return
				}
				var btns = document.querySelectorAll('uni-view')
				for (var i = 0; i < btns.length; i++) {
					if (btns[i].className.indexOf('send-btn') !== -1) {
						console.log('✓ 点击发送按钮(方法2)')
						forceClick(btns[i])
						return
					}
				}
				console.log('✗ 未找到发送按钮,尝试回车')
				textarea.dispatchEvent(new KeyboardEvent('keydown', {
					key: 'Enter',
					keyCode: 13,
					bubbles: true
				}))
			}, 500)
		}
	}

	// 点击重新匹配
	function clickRematch() {
		var btn = document.querySelector('.rematch-btn')
		if (btn) {
			console.log('✓ 点击重新匹配')
			forceClick(btn)
			firstAuto = true
			return true
		}
		var uniViews = document.querySelectorAll('uni-view')
		for (var i = 0; i < uniViews.length; i++) {
			var text = (uniViews[i].innerText || '').trim()
			if (text === '重新匹配' || text.indexOf('重新匹配') !== -1) {
				console.log('✓ 点击重新匹配(方法2)')
				forceClick(uniViews[i])
				firstAuto = true
				return true
			}
		}
		return false
	}

	// 点击离开
	function clickLeave() {
		var btn = document.querySelector('.leave-btn')
		if (!btn) btn = findByText('离开', true)
		if (btn) {
			console.log('✓ 点击离开')
			forceClick(btn)
			setTimeout(function() {
				var confirm = document.querySelector('.uni-modal__btn_primary')
				if (!confirm) {
					var btns = document.querySelectorAll('.uni-modal__btn')
					for (var i = 0; i < btns.length; i++) {
						if (btns[i].innerText.indexOf('确认离开') !== -1) {
							confirm = btns[i]
							break
						}
					}
				}
				if (!confirm) {
					var allDivs = document.querySelectorAll('div')
					for (var i = 0; i < allDivs.length; i++) {
						if ((allDivs[i].innerText || '').trim() === '确认离开') {
							confirm = allDivs[i]
							break
						}
					}
				}
				if (confirm) {
					console.log('✓ 点击确认离开')
					forceClick(confirm)
					setTimeout(function() {
						clickRematch()
					}, 1000)
				} else {
					console.log('✗ 未找到确认按钮')
					clickRematch()
				}
			}, 1000)
		}
	}

	// 主循环
	function mainLoop() {
		// 优先级1: 重新匹配按钮
		var rematchBtn = document.querySelector('.rematch-btn')
		if (rematchBtn) {
			console.log('✓ 检测到重新匹配按钮')
			forceClick(rematchBtn)
			firstAuto = true
			return
		}
		
		// 优先级2: 离开聊天按钮
		var leaveChatBtns = document.querySelectorAll('uni-view')
		for (var i = 0; i < leaveChatBtns.length; i++) {
			var btn = leaveChatBtns[i]
			var text = (btn.innerText || '').trim()
			if (text === '离开聊天' && btn.className.indexOf('bg-red') !== -1) {
				if (btn.getAttribute('data-clicked') === 'true') {
					return
				}
				console.log('✓ 对方走了')
				btn.setAttribute('data-clicked', 'true')
				forceClick(btn)
				setTimeout(function() {
					clickRematch()
				}, 1000)
				return
			}
		}

		// 优先级3: 性别判断
		var gender = getGender()
		if (!gender || !firstAuto) return

		if (gender === '女生') {
			firstAuto = false
			console.log('✓✓✓ 检测到女生')
			setTimeout(function() {
				sendMessage()
			}, 1000)
		}

		if (gender === '男生') {
			firstAuto = false
			console.log('✗✗✗ 检测到男生')
			setTimeout(function() {
				clickLeave()
			}, 500)
		}
	}

	// 初始化函数
	function init() {
		setInterval(function() {
			mainLoop()
		}, 500)
	}

	setTimeout(init, 2000)

})();