福利吧论坛好孩子看得见

好孩子才看得见,顺便签个到

Versión del día 18/07/2019. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name         福利吧论坛好孩子看得见
// @namespace    https://greasyfork.org/zh-CN/users/193133-pana
// @homepage     https://www.sailboatweb.com
// @version      1.8.2
// @description  好孩子才看得见,顺便签个到
// @author       pana
// @include      http*://www.wnflb19.com/*
// @include      http*://www.wnflb66.com/*
// @exclude      http*://*/member.php?mod=register
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// ==/UserScript==

(function() {
	'use strict';
	const urlReg = /^(https?:\/\/|magnet:\?xt=|ftp:\/\/|ed2k:\/\/|thunder:\/\/|flashget:\/\/|qqdl:\/\/|xfplay:\/\/)\S+/i;
	const baidupanReg = /^https?:\/\/pan\.baidu\.com\/s(hare)?\/./i;
	const codeReg = /^(.*提取码|\S+\s+)?[^A-Za-z0-9]*([A-Za-z0-9]{4})[^A-Za-z0-9]*$/i;
	const prefixLink = {
		magnet: /^https?:\/\/www\.wnflb[\d]{2}\.com\/magnet:\?xt=.*$/i,
		magnetSwitch: /^https?:\/\/www\.wnflb[\d]{2}\.com\//i,
	};
	const screenLink = {
		pojie: /^https?:\/\/www\.52pojie\.cn\/?$/i,
		pojieForum: /^https?:\/\/www\.52pojie\.cn\/(forum|home)\.php\?/i,
		pojieHtml: /^https?:\/\/www\.52pojie\.cn\/(forum|thread)-[\d]+-[\d]+(-[\d])?\.html$/i,
		fuliba: /^https?:\/\/www\.wnflb[\d]{2}\.com\/?$/i,
		fulibaForum: /^https?:\/\/www\.wnflb[\d]{2}\.com\/(home|forum)\.php\?/i,
		daybox: /^https?:\/\/www\.daybox\.net\/image\//i,
		imdb: /^https?:\/\/www\.imdb\.com\/title\//i,
		douban: /https?:\/\/movie\.douban\.com\/subject\//i,
	};

	function getCutLinkText(linkText) {
		if (linkText.length > 90) {
			let startText = linkText.slice(0, 50);
			let endText = linkText.slice(-30);
			return startText + '......' + endText
		}
		return linkText
	}
	function creatLink(linkHref) {
		return '<li style="list-style-type: disc;"><a style="font-size: 15px; color: blue; white-space: nowrap;" target="_blank" href="' + linkHref + '">' + getCutLinkText(linkHref) + '</a></li>'
	}
	function managePrefix(inputLink) {
		return prefixLink.magnet.test(inputLink) ? inputLink.replace(prefixLink.magnetSwitch, '') : inputLink
	}
	function manageText(textArray) {
		let tempArray = [];
		$.each(textArray, function(index, item) {
			if (urlReg.test(item)) {
				tempArray.push(urlReg.exec(item)[0])
			}
		});
		return managePrefix(tempArray)
	}
	function baidupanAuto(linkArray, baiduArray, textArray) {
		let concatArray = manageRepeatArray(manageText(linkArray.concat(textArray)));
		let countA = 0;
		let countB = 0;
		let indexA = [];
		let codeB = [];
		for (let i = 0; i < textArray.length; i++) {
			if (codeReg.test(textArray[i])) {
				let codeValue = codeReg.exec(textArray[i]).pop();
				if (codeB.indexOf(codeValue) === -1) {
					countB++;
					codeB.push(codeValue)
				}
			}
		}
		if (countB > 0) {
			for (let j = 0; j < concatArray.length; j++) {
				if (baidupanReg.test(concatArray[j])) {
					countA++;
					indexA.push(j)
				}
			}
			if (countB === countA) {
				for (let k = 0; k < indexA.length; k++) {
					concatArray[indexA[k]] = concatArray[indexA[k]] + '#' + codeB[k]
				}
			} else if (countB === baiduArray.length) {
				for (let l = 0; l < baiduArray.length; l++) {
					baiduArray[l].ele.text(baiduArray[l].eleContainer + '#' + codeB[l]);
					baiduArray[l].ele.attr('href', baiduArray[l].eleValue + '#' + codeB[l])
				}
			}
		}
		return managePrefix(concatArray)
	}
	function addGoodBoy(container, linkObj, textArray) {
		let goodBoyBtn = '<ul class="goodBoy"><p style="font-size: 15px; color: red">好孩子看得见:</p></ul>';
		container.after(goodBoyBtn);
		let goodBoy = $('.goodBoy');
		let concatArray = baidupanAuto(linkObj.linkArray, linkObj.baiduArray, textArray);
		if ((concatArray.length) === 0) {
			$('.goodBoy p').append('无')
		} else {
			$.each(concatArray, function(index, item) {
				goodBoy.append(creatLink(item))
			})
		}
	}
	function hideLink(inputLink) {
		let status = true;
		$.each(screenLink, function(index, item) {
			if (item.test(inputLink)) {
				status = false;
				return false
			}
		});
		return status
	}
	function manageRepeatArray(inputLinkArray) {
		let outputLinkArray = [];
		for (let i = 0, l = inputLinkArray.length; i < l; i++) {
			for (let j = i + 1; j < l; j++) {
				if (inputLinkArray[i] === inputLinkArray[j]) {
					++i;
					j = i
				}
			}
			outputLinkArray.push(inputLinkArray[i])
		}
		return outputLinkArray
	}
	function getPrueLink(inputLink) {
		return inputLink.replace(/(^https?:\/\/|\/$)/gi, '')
	}
	function findLink(container) {
		let link = container.find('a').not($('div.aimg_tip a')).not($('a:has(img.zoom)'));
		let tempObj = {
			linkArray: [],
			baiduArray: [],
		};
		for (let i = 0; i < link.length; i++) {
			let tempLink = link.eq(i).attr('href');
			let imgTemp = link.eq(i).find('img');
			if (imgTemp.length !== 0) {
				if (imgTemp.attr('src') !== tempLink) {
					tempObj.linkArray.push(tempLink)
				}
			} else if ((getPrueLink(link.eq(i).text()) !== getPrueLink(tempLink)) && (hideLink(tempLink))) {
				tempObj.linkArray.push(tempLink)
			} else if (baidupanReg.test(tempLink)) {
				let baiduObj = {
					eleValue: tempLink,
					eleContainer: link.eq(i).text(),
					ele: link.eq(i),
				};
				tempObj.baiduArray.push(baiduObj)
			}
		}
		return tempObj
	}
	function judgeColor(rgbColorValue) {
		let rgbValue = rgbColorValue.replace('rgb(', '').replace(')', '');
		let rgbValueArray = rgbValue.split(',');
		let grayLevel = rgbValueArray[0] * 0.299 + rgbValueArray[1] * 0.587 + rgbValueArray[2] * 0.114;
		return grayLevel >= 192
	}
	function rgbaToRgb(colorString) {
		let colorValue = colorString.match(/[\d]+/g);
		if (colorValue.length > 3) {
			return 'rgb(' + colorValue[0] + ', ' + colorValue[2] + ', ' + colorValue[3] + (')')
		}
		return colorString
	}
	function displayText(container, newTextColor, newTextBackgroundColor) {
		let text = container.find('font');
		let tempArray = [];
		for (let i = 0; i < text.length; i++) {
			if (judgeColor(rgbaToRgb(text.eq(i).css('color')))) {
				text.eq(i).css('color', newTextColor);
				tempArray.push(text.eq(i).text())
			}
			if (rgbaToRgb(text.eq(i).css('background-color')) === rgbaToRgb(text.eq(i).css('color'))) {
				text.eq(i).css('background-color', newTextBackgroundColor);
				text.eq(i).css('color', newTextColor);
				tempArray.push(text.eq(i).text())
			} else if (!judgeColor(rgbaToRgb(text.eq(i).css('background-color')))) {
				text.eq(i).css('background-color', newTextBackgroundColor)
			}
		}
		return tempArray
	}
	function init() {
		let old_url = location.href;
		if ((old_url.indexOf('page=') === -1) || (/page=1(&_dsign=[a-z0-9]+)?$/i.test(old_url))) {
			let mainBtn = $('div.cm').eq(0);
			let tdBtn = $('td.t_f').eq(0);
			let textBtn = $('td.t_f:first');
			addGoodBoy(mainBtn, findLink(tdBtn), displayText(textBtn, 'red', 'white'))
		}
		let checkBtn = $('a#fx_checkin_topb');
		if (checkBtn.attr('initialized') !== 'true') {
			checkBtn.click()
		}
	}
	init()
})();