福利吧论坛好孩子看得见

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

Versión del día 03/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.5.0
// @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 = /^[^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-[\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, -1);
			return startText + '......' + endText
		}
		return linkText
	}
	function creatLink(linkHref) {
		let tempLink = '<li style="list-style-type: disc;"><a style="font-size: 15px; color: blue; white-space: nowrap;" target="_blank" href="' + linkHref + '">' + getCutLinkText(linkHref) + '</a></li>';
		return tempLink
	}
	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].replace(/\/$/i, ''))
			}
		});
		return managePrefix(tempArray)
	}
	function baidupanAuto(linkArray, textArray) {
		let concatArray = manageRepeatArray(manageText(linkArray.concat(textArray)));
		let countA = 0;
		let countB = 0;
		let indexA = -1;
		let indexB = -1;
		for (let i = 0; i < concatArray.length; i++) {
			if (baidupanReg.test(concatArray[i])) {
				countA++;
				indexA = i;
				if (countA > 1) {
					break
				}
			}
		}
		for (let j = 0; j < textArray.length; j++) {
			if (codeReg.test(textArray[j])) {
				countB++;
				indexB = j;
				if (countB > 1) {
					break
				}
			}
		}
		if ((countA === 1) && (countB === 1)) {
			concatArray[indexA] = concatArray[indexA] + '#' + codeReg.exec(textArray[indexB])[1]
		}
		return managePrefix(concatArray)
	}
	function addGoodBoy(container, linkArray, textArray) {
		let goodBoyBtn = '<ul class="goodBoy"><p style="font-size: 15px; color: red">好孩子看得见:</p></ul>';
		container.after(goodBoyBtn);
		let goodBoy = $('.goodBoy');
		let concatArray = baidupanAuto(linkArray, 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 tempArray = [];
		for (let i = 0; i < link.length; i++) {
			let imgTemp = link.eq(i).find('img');
			if (imgTemp.length !== 0) {
				if (imgTemp.attr('src') !== link.eq(i).attr('href')) {
					tempArray.push(link.eq(i).attr('href'))
				}
			} else if ((getPrueLink(link.eq(i).text()) !== getPrueLink(link.eq(i).attr('href'))) && (hideLink(link.eq(i).attr('href')))) {
				tempArray.push(link.eq(i).attr('href'))
			}
		}
		return manageRepeatArray(tempArray)
	}
	function displayText(container, oldTextColor, newTextColor) {
		let text = container.find('font');
		let tempArray = [];
		for (let i = 0; i < text.length; i++) {
			if (text.eq(i).css('color') === oldTextColor) {
				text.eq(i).css('color', newTextColor);
				tempArray.push(text.eq(i).text())
			}
		}
		return manageRepeatArray(tempArray)
	}
	function init() {
		let old_url = location.href;
		if ((old_url.indexOf('page=') === -1) || (/page=1$/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, 'rgb(255, 255, 255)', 'red'))
		}
		let checkBtn = $('a#fx_checkin_topb');
		if (checkBtn.attr('initialized') !== 'true') {
			checkBtn.click()
		}
	}
	init()
})();