Greasy Fork is available in English.
验证码自动识别填写,Ctrl+Enter快捷键发表评论,短评实时字数统计,资源页简介区百度网盘链接识别、补全、激活
当前为
// ==UserScript==
// @name 恋爱游戏网+
// @namespace http://tampermonkey.net/code_recongnize
// @version 2021.04.16.1
// @description 验证码自动识别填写,Ctrl+Enter快捷键发表评论,短评实时字数统计,资源页简介区百度网盘链接识别、补全、激活
// @author PY-DNG
// @icon https://www.lianaiyx.com/e/data/images/info.jpg
// @include https://www.lianaiyx.com/
// @include https://www.lianaiyx.com/GalGame/*
// @include https://www.lianaiyx.com/yangcheng/*
// @include https://www.lianaiyx.com/monijingying/*
// @include https://www.lianaiyx.com/celve/*
// @include https://www.lianaiyx.com/jiemi/*
// @include https://www.lianaiyx.com/ss/*
// @include https://www.lianaiyx.com/yxzy/*
// @include https://www.lianaiyx.com/gonglve/*
// @include https://www.lianaiyx.com/e/pl/*
// @require http://greasyfork.icu/scripts/408740-%E6%81%8B%E7%88%B1%E6%B8%B8%E6%88%8F%E7%BD%914%E4%BD%8D%E6%95%B0%E5%AD%97%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB/code/%E6%81%8B%E7%88%B1%E6%B8%B8%E6%88%8F%E7%BD%914%E4%BD%8D%E6%95%B0%E5%AD%97%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB.js?version=837246
// ==/UserScript==
(function() {
'use strict';
// 用户常量 - 用户可修改/自定义
// 允许出现在链接里面的中文字符/特殊字符,用于识别经过防和谐处理的度盘链接,可自行添加
const TEXT_CHINESEINLINKS = '删除汉字文字去除我盘点百度杠复制链接和谐河蟹防止抽风度娘网盘';
// 开发者模式开关
const developer = false;
// 内置常量
const REGEXP_DUPANSHARE = new RegExp('^(/s/|s/|/)', 'g');
const REGEXP_LINKRCGNZER = new RegExp('(/s/|s/|/)?[\\w_\\-{CHINESE}]{7,}'.replaceAll('{CHINESE}', TEXT_CHINESEINLINKS.replaceAll('\\', '\\\\')), 'g');
const REGEXP_CHNSRCGNZER = new RegExp('[{CHINESE}]+'.replaceAll('{CHINESE}', TEXT_CHINESEINLINKS.replaceAll('\\', '\\\\')), 'g');
const URL_API_DOWNLOAD = 'https://www.lianaiyx.com/e/DownSys/GetDown/?classid=11&id={GAMEID}&pathid=0';
const URL_HOST_BAIDUPAN = 'https://pan.baidu.com/s/';
const TEXT_TEXTHINT_ORIGINAL = '短评最多字数:140字;超过字数请发表长评。';
const TEXT_CHARACTERCOUNT = '短评字数统计:{CURCOUNT}/140字;超过140字请发布长评';
// 获取DOM元素
const input = document.getElementById('key');
const focusEvent = new Event('focus');
const codeImage = document.getElementById('KeyImgpl') ? document.getElementById('KeyImgpl') : document.getElementById('KeyImg');
const saytext = document.querySelector('#saytext');
// 获取标签页API(只要API第一部分,如: 'yxzy', 'GalGame')
const API = window.location.href.replace(/https?:\/\/(.*?\.){1,2}.*?\//, '').replace(/\?.*/, '').replace(/\/.*/g, '');
// 通用页面操作
codeFill();
hotkeySay();
saytextCounting();
// 根据不同API页面执行不同附加功能
switch (API) {
// Dwonload page
case 'yxzy':
pageDownload();
break;
// Other pages
default:
console.log(API);
}
// 自动识别填写验证码
function codeFill() {
if (codeImage) {
codeImage.addEventListener('load', function() {
const code = rec_image(codeImage);
if (code) {
input.value = code;
} else {
input.dispatchEvent(focusEvent);
}
})
input.dispatchEvent(focusEvent);
}
}
// Ctrl+Enter 发表评论
function hotkeySay() {
if (saytext) {
saytext.addEventListener('keydown', function() {
let keycode = event.keyCode;
if (keycode === 13 && event.ctrlKey && !event.altKey) {
document.querySelector('#saypl').submit();
}
})
}
}
// 短评实时字数统计
function saytextCounting() {
if (saytext) {
const texthint = getTexthintElement();
const refreshCount = function() {texthint.textContent = TEXT_CHARACTERCOUNT.replace('{CURCOUNT}', String(saytext.value.length));};
// 首先统计一次字数
refreshCount();
// 当用户输入时,更新字数统计
saytext.addEventListener('input', refreshCount);
// 用户使用输入设备交互时,更新字数统计/*_*毕竟有些时候用户不输入字符,内容也会被JS动态修改,对吧?*_*/
saytext.addEventListener('focus', refreshCount);
saytext.addEventListener('mousedown', refreshCount);
saytext.addEventListener('keydown', refreshCount);
saytext.addEventListener('keyup', refreshCount);
function getTexthintElement() {
const allChilds = document.querySelector('#texthint').parentElement.childNodes;
for (let i = 0; i < allChilds.length; i++) {
if (allChilds[i].textContent.indexOf(TEXT_TEXTHINT_ORIGINAL) !== -1) {
return allChilds[i];
}
}
}
}
}
// 游戏资源页
function pageDownload() {
// 获取元素/信息
const downloadLink = document.querySelector('.downpath').querySelector('a:nth-child(1)');
const gameId = location.href.match(/(\d+?)\.html/)[1];
// 检测是否允许下载
const downloadEnabled = downloadLink.href !== '';
// 如果不允许下载,就添加下载链接
if (!downloadEnabled) {
downloadLink.href = URL_API_DOWNLOAD.replace('{GAMEID}', gameId);
downloadLink.target = '_blank';
downloadLink.innerText = '[恋网下载API已关闭:(]';
}
// 检测是否有度盘后缀
const infoEle = document.querySelector('.downbox > tbody:nth-child(1) > tr:nth-child(13) > td:nth-child(2) > div:nth-child(1)');
const dupanSuffixes = infoEle.innerText.match(REGEXP_LINKRCGNZER);
if (dupanSuffixes) {
const validSffxs = [];
const dupanLinks = [];
const dupanHTMLs = [];
for (let i = 0; i < dupanSuffixes.length; i++) {
validSffxs[i] = dupanSuffixes[i].replace(REGEXP_CHNSRCGNZER, '').replace(REGEXP_DUPANSHARE, '');
dupanLinks[i] = URL_HOST_BAIDUPAN + validSffxs[i];
dupanHTMLs[i] = '<span class=\'downpath\'><a href = \'{LINK}\' target=\'_blank\'>{LINK}</a></span>'.replaceAll('{LINK}', dupanLinks[i]);
infoEle.innerText = infoEle.innerText.replace(dupanSuffixes[i], dupanLinks[i]);
infoEle.innerHTML = infoEle.innerHTML.replace(dupanLinks[i], dupanHTMLs[i]);
}
if (developer) {console.log(dupanSuffixes, validSffxs, dupanLinks, dupanHTMLs);}
}
}
})();