福利吧论坛好孩子看得见

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

Versión del día 01/08/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.9.4
// @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 URL_REG = /^(https?:\/\/|magnet:\?xt=|ftp:\/\/|ed2k:\/\/|thunder:\/\/|flashget:\/\/|qqdl:\/\/|xfplay:\/\/)\S+/i;
	const BAIDUPAN_REG = /^https?:\/\/pan\.baidu\.com\/s(hare)?\/./i;
	const CODE_REG = /^(.*提取码|\S+\s+)?[^A-Za-z0-9]*([A-Za-z0-9]{4})[^A-Za-z0-9]*$/i;
	const MISSING_HEADER_BAIDUPAN_REG = /^\/?s(hare)?\/\S+/i;
	const PREFIX_LINK_REG = {
		MAGNET: /^https?:\/\/www\.wnflb[\d]{2}\.com\/magnet:\?xt=.*$/i,
		MAGNET_SWITCH: /^https?:\/\/www\.wnflb[\d]{2}\.com\//i,
	};
	const FILTER_LINK_REG = {
		POJIE: /^https?:\/\/www\.52pojie\.cn\/?$/i,
		POJIE_FORUM: /^https?:\/\/www\.52pojie\.cn\/(forum|home|misc)\.php\?/i,
		POJIE_HTML: /^https?:\/\/www\.52pojie\.cn\/(forum|thread)-[\d]+-[\d]+(-[\d])?\.html$/i,
		FULIBA: /^https?:\/\/www\.wnflb[\d]{2}\.com\/?$/i,
		FULIBA_FORUM: /^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 get_Cut_Link_Text(link_text) {
		return (link_text.length > 90) ? (link_text.slice(0, 50) + '......' + link_text.slice(-25)) : (link_text)
	}
	function create_Link(link_href) {
		return '<li style="list-style-type: disc;"><a style="font-size: 15px; color: blue; white-space: nowrap;" target="_blank" href="' + link_href + '">' + get_Cut_Link_Text(link_href) + '</a></li>'
	}
	function manage_Prefix(input_link_array) {
		let return_link_array = [];
		$.each(input_link_array, function(index, item) {
			return_link_array.push(PREFIX_LINK_REG.MAGNET.test(item) ? item.replace(PREFIX_LINK_REG.MAGNET_SWITCH, '') : item)
		});
		return return_link_array
	}
	function manage_Text(text_array) {
		let temp_array = [];
		$.each(text_array, function(index, item) {
			if (URL_REG.test(item)) {
				temp_array.push(URL_REG.exec(item)[0])
			}
		});
		return manage_Prefix(temp_array)
	}
	function decode_Link(input_link_array) {
		$.each(input_link_array, function(index, item) {
			input_link_array[index] = decodeURI(item)
		});
		return input_link_array
	}
	function baidupan_Auto_Event(link_array, baidu_array, text_array) {
		let concat_array = manage_Repeat_Array(decode_Link(manage_Text(link_array.concat(text_array))));
		let index_a = [];
		let code_b = [];
		let link_m = [];
		for (let i = 0; i < text_array.length; i++) {
			if (CODE_REG.test(text_array[i])) {
				let code_value = CODE_REG.exec(text_array[i]).pop();
				if (code_b.indexOf(code_value) === -1) {
					code_b.push(code_value)
				}
			}
			if (MISSING_HEADER_BAIDUPAN_REG.test(text_array[i])) {
				let link_miss_value = MISSING_HEADER_BAIDUPAN_REG.exec(text_array[i])[0];
				if (link_m.indexOf(link_miss_value) === -1) {
					link_m.push(link_miss_value)
				}
			}
		}
		if (link_m.length > 0) {
			for (let m = 0; m < link_m.length; m++) {
				link_m[m] = (/^\//i.test(link_m[m])) ? ('https://pan.baidu.com' + link_m[m]) : ('https://pan.baidu.com/' + link_m[m])
			}
			concat_array = manage_Repeat_Array(concat_array.concat(link_m))
		}
		if (code_b.length > 0) {
			for (let j = 0; j < concat_array.length; j++) {
				if (BAIDUPAN_REG.test(concat_array[j])) {
					index_a.push(j)
				}
			}
			if (code_b.length === index_a.length) {
				for (let k = 0; k < index_a.length; k++) {
					concat_array[index_a[k]] = concat_array[index_a[k]] + '#' + code_b[k]
				}
			} else if (code_b.length === baidu_array.length) {
				for (let l = 0; l < baidu_array.length; l++) {
					baidu_array[l].ele.text(baidu_array[l].ele_container + '#' + code_b[l]);
					baidu_array[l].ele.attr('href', baidu_array[l].ele_value + '#' + code_b[l])
				}
			}
		}
		return manage_Prefix(concat_array)
	}
	function add_Good_Boy_Event(container, link_obj, text_array) {
		let good_boy_btn = '<ul class="goodBoy"><p style="font-size: 15px; color: red">好孩子看得见:</p></ul>';
		container.after(good_boy_btn);
		let good_boy = $('.goodBoy');
		let concat_array = baidupan_Auto_Event(link_obj.link_array, link_obj.baidu_array, text_array);
		if ((concat_array.length) === 0) {
			$('.goodBoy p').append('无')
		} else {
			$.each(concat_array, function(index, item) {
				good_boy.append(create_Link(item))
			})
		}
	}
	function filter_Link(input_link) {
		let status = true;
		$.each(FILTER_LINK_REG, function(index, item) {
			if (item.test(input_link)) {
				status = false;
				return false
			}
		});
		return status
	}
	function manage_Repeat_Array(input_link_array) {
		let output_link_array = [];
		for (let i = 0, l = input_link_array.length; i < l; i++) {
			for (let j = i + 1; j < l; j++) {
				if (input_link_array[i] === input_link_array[j]) {
					++i;
					j = i
				}
			}
			output_link_array.push(input_link_array[i])
		}
		return output_link_array
	}
	function get_Pure_Link(input_link) {
		return input_link.replace(/(^https?:\/\/|\/$)/gi, '')
	}
	function find_Link(container) {
		let link = container.find('a').not($('div.aimg_tip a')).not($('a:has( > img.zoom)'));
		let temp_obj = {
			link_array: [],
			baidu_array: [],
		};
		for (let i = 0; i < link.length; i++) {
			let temp_link = link.eq(i).attr('href');
			let temp_img = link.eq(i).find('img');
			if (temp_img.length !== 0) {
				if (temp_img.attr('src') !== temp_link) {
					if ((get_Pure_Link(link.eq(i).text()) !== get_Pure_Link(temp_link)) && (filter_Link(temp_link))) {
						temp_obj.link_array.push(temp_link)
					} else if (BAIDUPAN_REG.test(temp_link)) {
						let baidu_obj = {
							ele_value: temp_link,
							ele_container: link.eq(i).text(),
							ele: link.eq(i),
						};
						temp_obj.baidu_array.push(baidu_obj)
					}
				}
			} else if ((get_Pure_Link(link.eq(i).text()) !== get_Pure_Link(temp_link)) && (filter_Link(temp_link))) {
				temp_obj.link_array.push(temp_link)
			} else if (BAIDUPAN_REG.test(temp_link)) {
				let baidu_obj = {
					ele_value: temp_link,
					ele_container: link.eq(i).text(),
					ele: link.eq(i),
				};
				temp_obj.baidu_array.push(baidu_obj)
			}
		}
		return temp_obj
	}
	function judge_Color(rgb_color_value) {
		if (/rgb\(/i.test(rgb_color_value)) {
			let rgb_value = rgb_color_value.replace('rgb(', '').replace(')', '');
			let rgb_value_array = rgb_value.split(',');
			let gray_level = rgb_value_array[0] * 0.299 + rgb_value_array[1] * 0.587 + rgb_value_array[2] * 0.114;
			return gray_level >= 192
		} else if (/rgba\(/i.test(rgb_color_value)) {
			let rgba_value = rgb_color_value.replace('rgba(', '').replace(')', '');
			let rgba_value_array = rgba_value.split(',');
			if (rgba_value_array[3] <= 0.2) {
				return true
			} else {
				let gray_level_2 = rgba_value_array[0] * 0.299 + rgba_value_array[1] * 0.587 + rgba_value_array[2] * 0.114;
				return gray_level_2 >= 192
			}
		}
		return false
	}
	function rgb_To_Rgba(color_string) {
		let color_value = color_string.match(/[\d]+/g);
		if (color_value.length === 3) {
			return 'rgba(' + color_value[0] + ', ' + color_value[1] + ', ' + color_value[2] + (', 1)')
		}
		return color_string
	}
	function display_Text(container, new_text_color, new_text_background_color) {
		let text = container.find('font');
		let temp_array = [];
		for (let i = 0; i < text.length; i++) {
			if (judge_Color(text.eq(i).css('color'))) {
				text.eq(i).css('color', new_text_color);
				temp_array.push(text.eq(i).text())
			}
			if (rgb_To_Rgba(text.eq(i).css('background-color')) === rgb_To_Rgba(text.eq(i).css('color'))) {
				text.eq(i).css('background-color', new_text_background_color);
				text.eq(i).css('color', new_text_color);
				temp_array.push(text.eq(i).text())
			} else if (!judge_Color(text.eq(i).css('background-color'))) {
				text.eq(i).css('background-color', new_text_background_color);
				text.eq(i).css('color', new_text_color);
				temp_array.push(text.eq(i).text())
			}
		}
		return temp_array
	}
	function init() {
		let old_url = location.href;
		if ((old_url.indexOf('page=') === -1) || (/page=1(&_dsign=[a-z0-9]+)?$/i.test(old_url))) {
			let main_btn = $('div.cm').eq(0);
			let td_btn = $('td.t_f').eq(0);
			let text_btn = $('td.t_f:first');
			add_Good_Boy_Event(main_btn, find_Link(td_btn), display_Text(text_btn, 'red', 'white'))
		}
		let check_btn = $('a#fx_checkin_topb');
		if (check_btn.attr('initialized') !== 'true') {
			check_btn.click()
		}
	}
	init()
})();