福利吧论坛好孩子看得见

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

Versión del día 06/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      2.0.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 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-z0-9]*([a-z0-9]{4})[^a-z0-9]*$/i;
	const MISSING_HEADER_BAIDUPAN_REG = /^\/?s(hare)?\/\S+/i;
	const MISSING_HEADER_BAIDUPAN_TEST_REG = /^([a-z0-9_-]+)\s+[a-z0-9]{4}/i;
	const HASH_REG = /^[a-z0-9]{32}$|^[a-z0-9]{40}$/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,
		PHOTO_WEIBO: /^https?:\/\/photo\.weibo\.com\//i,
	};

	function get_Cut_Link_Text(link_text) {
		return (link_text.length > 80) ? (link_text.slice(0, 45) + '......' + link_text.slice(-25)) : (link_text)
	}
	function copy_Event(copy_text) {
		let o_input = document.createElement('input');
		o_input.value = copy_text;
		document.body.appendChild(o_input);
		o_input.select();
		document.execCommand("Copy");
		o_input.className = 'o_input';
		o_input.style.display = 'none'
	}
	function create_Link(link_href) {
		let link_li = document.createElement('li');
		link_li.style.listStyleType = 'disc';
		let link_a = document.createElement('a');
		link_a.title = '点击访问';
		link_a.href = link_href;
		link_a.target = '_blank';
		link_a.innerText = get_Cut_Link_Text(link_href);
		link_a.style.display = 'inline-block';
		link_a.style.fontSize = '15px';
		link_a.style.color = 'blue';
		link_a.style.whiteSpace = 'nowrap';
		let copy_a = document.createElement('a');
		copy_a.className = 'copy_btn';
		copy_a.title = '复制链接';
		copy_a.href = 'javascript:;';
		copy_a.target = '_self';
		copy_a.innerText = '复制';
		copy_a.style.display = 'inline-block';
		copy_a.style.fontSize = '15px';
		copy_a.style.color = 'blue';
		copy_a.style.marginLeft = '20px';
		copy_a.style.textDecoration = 'underline';
		copy_a.addEventListener('click', function() {
			copy_Event(link_href);
			this.style.color = '#f60';
			this.title = '复制成功'
		});
		link_li.appendChild(link_a);
		link_li.appendChild(copy_a);
		return link_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_obj_array, baidu_obj_array, text_array) {
		let link_array = [];
		let link_text_array = [];
		$.each(link_obj_array, function(index, item) {
			link_array.push(item.ele_value);
			link_text_array.push(item.ele_container)
		});
		let concat_link_array = manage_Repeat_Array(decode_Link(manage_Text(link_array.concat(text_array))));
		let concat_text_array = manage_Repeat_Array(decode_Link(link_text_array.concat(text_array)));
		let index_a = [];
		let code_b = [];
		let link_m = [];
		let hash_h = [];
		for (let i = 0; i < concat_text_array.length; i++) {
			if (CODE_REG.test(concat_text_array[i])) {
				let code_value = CODE_REG.exec(concat_text_array[i]).pop();
				if (code_b.indexOf(code_value) === -1) {
					code_b.push(code_value)
				}
			}
			if (MISSING_HEADER_BAIDUPAN_REG.test(concat_text_array[i])) {
				let link_miss_value = MISSING_HEADER_BAIDUPAN_REG.exec(concat_text_array[i])[0];
				if (link_m.indexOf(link_miss_value) === -1) {
					link_m.push(link_miss_value)
				}
			} else if (MISSING_HEADER_BAIDUPAN_TEST_REG.test(concat_text_array[i])) {
				let link_miss_test_value = MISSING_HEADER_BAIDUPAN_TEST_REG.exec(concat_text_array[i])[1];
				if (link_m.indexOf(link_miss_test_value) === -1) {
					link_m.push('/s/' + link_miss_test_value)
				}
			} else if (HASH_REG.test(concat_text_array[i])) {
				hash_h.push(concat_text_array[i])
			}
		}
		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_link_array = manage_Repeat_Array(concat_link_array.concat(link_m))
		}
		if (hash_h.length > 0) {
			for (let h = 0; h < hash_h.length; h++) {
				hash_h[h] = 'magnet:?xt=urn:btih:' + hash_h[h]
			}
			concat_link_array = manage_Repeat_Array(concat_link_array.concat(hash_h))
		}
		if (code_b.length > 0) {
			for (let j = 0; j < concat_link_array.length; j++) {
				if (BAIDUPAN_REG.test(concat_link_array[j])) {
					index_a.push(j)
				}
			}
			if (code_b.length === index_a.length) {
				for (let k = 0; k < index_a.length; k++) {
					concat_link_array[index_a[k]] = concat_link_array[index_a[k]] + '#' + code_b[k]
				}
			} else if (code_b.length === baidu_obj_array.length) {
				for (let l = 0; l < baidu_obj_array.length; l++) {
					baidu_obj_array[l].ele.text(baidu_obj_array[l].ele_container + '#' + code_b[l]);
					baidu_obj_array[l].ele.attr('href', baidu_obj_array[l].ele_value + '#' + code_b[l])
				}
			}
		}
		return manage_Prefix(concat_link_array)
	}
	function create_Good_Boy_Button(link_obj, text_array) {
		let concat_array = baidupan_Auto_Event(link_obj.link_obj_array, link_obj.baidu_obj_array, text_array);
		if ((concat_array.length) !== 0) {
			let good_boy_btn = document.createElement('ul');
			good_boy_btn.className = 'goodBoy';
			let good_boy_p = document.createElement('p');
			good_boy_p.innerText = '好孩子看得见:';
			good_boy_p.style.color = 'red';
			good_boy_p.style.fontSize = '15px';
			good_boy_btn.appendChild(good_boy_p);
			$.each(concat_array, function(index, item) {
				good_boy_btn.appendChild(create_Link(item))
			});
			return good_boy_btn
		}
		return ''
	}
	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 contrast_Text_And_Link(text_value, link_value) {
		let status = true;
		text_value = get_Pure_Link(text_value);
		link_value = get_Pure_Link(link_value);
		if (/\s...\s/i.test(text_value)) {
			status = false;
			let temp_array = text_value.split(' ... ');
			$.each(temp_array, function(index, item) {
				if (link_value.indexOf(item) === -1) {
					status = true;
					return false
				}
			})
		} else if (text_value === link_value) {
			status = false
		}
		return status
	}
	function find_Link(container) {
		let link = container.find('a').not($('div.aimg_tip a')).not($('a:has( > img.zoom)'));
		let temp_obj = {
			link_obj_array: [],
			baidu_obj_array: [],
		};
		for (let i = 0; i < link.length; i++) {
			let temp_link = link.eq(i).attr('href');
			if (filter_Link(temp_link)) {
				let temp_img = link.eq(i).find('img');
				if ((temp_img.length === 0) || ((temp_img.length !== 0) && (temp_img.attr('src') !== temp_link))) {
					let temp_text = link.eq(i).text();
					if (contrast_Text_And_Link(temp_text, temp_link)) {
						let link_obj = {
							ele_value: temp_link,
							ele_container: temp_text,
							ele: link.eq(i),
						};
						temp_obj.link_obj_array.push(link_obj)
					} else if (BAIDUPAN_REG.test(temp_link)) {
						let baidu_obj = {
							ele_value: temp_link,
							ele_container: temp_text,
							ele: link.eq(i),
						};
						temp_obj.baidu_obj_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 main_btn = $('div.cm');
		let td_btn = $('td.t_f');
		for (let i = 0; i < main_btn.length; i++) {
			main_btn.eq(i).after(create_Good_Boy_Button(find_Link(td_btn.eq(i)), display_Text(td_btn.eq(i), 'red', 'white')))
		}
		let check_btn = $('a#fx_checkin_topb');
		if (check_btn.attr('initialized') !== 'true') {
			check_btn.click()
		}
	}
	init()
})();