Javlibrary - Auxiliary script

Record and display your own ratings; record and identify your favorite actors, directors, makers, and labels.

// ==UserScript==
// @name                Javlibrary - 辅助脚本
// @name:zh-CN          Javlibrary - 辅助脚本
// @name:zh-TW          Javlibrary - 輔助腳本
// @name:en             Javlibrary - Auxiliary script
// @name:ja             Javlibrary - 補助スクリプト
// @namespace           https://sleazyfork.org/zh-CN/users/193133-pana
// @version             4.3.4
// @description         记录并显示自己的评分;记录并标识喜爱的演员、导演、制作商和发行商。
// @description:zh-CN   记录并显示自己的评分;记录并标识喜爱的演员、导演、制作商和发行商。
// @description:zh-TW   記錄並顯示自己的評分;記錄並標識喜愛的演員、導演、製作商和發行商。
// @description:en      Record and display your own ratings; record and identify your favorite actors, directors, makers, and labels.
// @description:ja      あなた自身の評価を記録して表示し、あなたの好きな俳優、監督、メーカー、そしてレーベルを記録しそして識別しなさい。
// @author              pana
// @include             http*://*javlibrary.com/*
// @include             http*://www.c32r.com/*
// @include             http*://www.m34z.com/*
// @grant               GM_getValue
// @grant               GM_setValue
// ==/UserScript==

(function() {
	'use strict';
	const FAVORITE_STRING = ' ❤';
	const LANG = {
		ZH_CN: {
			button_text: '自动提取',
			score_string: '评分',
			director_string: '导演',
			maker_string: '制作商',
			label_string: '发行商',
			actor_string: '演员',
			hots_string: '热度: ',
			hour_string: ' 小时 ',
			min_string: ' 分钟',
			extracting_string: ' 提取中...',
			extract_completed_string: ' 提取完成!',
		},
		ZH_TW: {
			button_text: '自動提取',
			score_string: '評分',
			director_string: '導演',
			maker_string: '製作商',
			label_string: '發行商',
			actor_string: '演員',
			hots_string: '熱度: ',
			hour_string: ' 小時 ',
			min_string: ' 分鐘',
			extracting_string: ' 提取中...',
			extract_completed_string: ' 提取完成!',
		},
		EN: {
			button_text: 'Automatically extract ',
			score_string: 'score',
			director_string: 'directors',
			maker_string: 'makers',
			label_string: 'labels',
			actor_string: 'actors',
			hots_string: 'hots: ',
			hour_string: ' hour(s) ',
			min_string: ' min(s)',
			extracting_string: ' Extracting...',
			extract_completed_string: ' Extraction completed!',
		},
		JA: {
			button_text: '自動抽出',
			score_string: '評価',
			director_string: '監督',
			maker_string: 'メーカー',
			label_string: 'レーベル',
			actor_string: '俳優',
			hots_string: '熱: ',
			hour_string: ' 時 ',
			min_string: ' 分',
			extracting_string: ' 抽出する...',
			extract_completed_string: ' 抽出完了!',
		},
	};
	var lang_value = {
		button_text: '自动提取',
		score_string: '评分',
		director_string: '导演',
		maker_string: '制作商',
		label_string: '发行商',
		actor_string: '演员',
		hots_string: '热度: ',
		hour_string: ' 小时 ',
		min_string: ' 分钟',
		extracting_string: ' 提取中...',
		extract_completed_string: ' 提取完成!',
	};
	var score_handle = {
		jav_code: '',
		user_score: '',
	};
	const JAV_REG = {
		INDEX: /\.com\/.*\/$/i,
		VL_UPDATE: /\.com\/.*\/vl_update\.php/i,
		VL_NEWRELEASE: /\.com\/.*\/vl_newrelease\.php/i,
		VL_NEWENTRIES: /\.com\/.*\/vl_newentries\.php/i,
		VL_MOSTWANTED: /\.com\/.*\/vl_mostwanted\.php/i,
		VL_BESTRATED: /\.com\/.*\/vl_bestrated\.php/i,
		VL_SEARCH: /\.com\/.*\/vl_search/i,
		VL_GENRE: /\.com\/.*\/vl_genre\.php/i,
		VL_STAR: /\.com\/.*\/vl_star\.php/i,
		VL_DIRECTOR: /\.com\/.*\/vl_director\.php/i,
		VL_MAKER: /\.com\/.*\/vl_maker\.php/i,
		VL_LABEL: /\.com\/.*\/vl_label\.php/i,
		INFO: /\.com\/.*\/\?v=/i,
		MV_RATED: /\.com\/.*\/mv_rated\.php/i,
		MV_COMMENTED: /\.com\/.*\/mv_commented\.php/i,
		MV_WATCHED: /\.com\/.*\/mv_watched\.php/i,
		MV_OWNED: /\.com\/.*\/mv_owned\.php/i,
		MV_WANTED: /\.com\/.*\/mv_wanted\.php/i,
		MV_VISITED: /\.com\/.*\/mv_visited\.php/i,
		MV_FAVDIRECTORS: /\.com\/.*\/mv_favdirectors\.php/i,
		MV_FAVMAKERS: /\.com\/.*\/mv_favmakers\.php/i,
		MV_FAVLABELS: /\.com\/.*\/mv_favlabels\.php/i,
		MV_FAVSTARS: /\.com\/.*\/mv_favstars\.php/i,
		TL_BESTREVIEWS: /\.com\/.*\/tl_bestreviews\.php/i,
		VIDEOREVIEWS: /\.com\/.*\/videoreviews\.php/i,
		VIDEOCOMMENTS: /\.com\/.*\/videocomments\.php/i,
		MYACCOUNT: /\.com\/.*\/myaccount\.php/i,
		USERPOSTS: /\.com\/.*\/userposts\.php/i,
		USERWANTED: /\.com\/.*\/userwanted\.php/i,
		USERWATCHED: /\.com\/.*\/userwatched\.php/i,
		USEROWNED: /\.com\/.*\/userowned\.php/i,
		USERSWANTED: /\.com\/.*\/userswanted\.php/i,
		USERSWATCHED: /\.com\/.*\/userswatched\.php/i,
		USERSOWNED: /\.com\/.*\/usersowned\.php/i,
	};
	const DISPLAY_REG = {
		THUMB: /\.php\?thumb/i,
		LIST: /\.php\?list/i,
	};
	const CODE_REG = {
		TITLE: /^[a-z0-9]+-[a-z0-9]+\s.{2}/i,
	};
	const SCORE_COLOR = {
		__10__: '#A382EB',
		__9__: '#9719A9',
		__8__: '#DC0BC9',
		__7__: '#C31B01',
		__6__: '#E93303',
		__5__: '#EB932F',
		__4__: '#ECEA09',
		__3__: '#2CA570',
		__2__: '#3AC8F8',
		__1__: '#3F8FE8',
	};
	var javlibrary_config = {};
	var default_config = {
		score_array: [],
		actor_array: [],
		director_array: [],
		maker_array: [],
		label_array: [],
		extract_value: {
			extract_score: false,
			extract_director: false,
			extract_maker: false,
			extract_label: false,
			extract_actor: false,
		},
	};

	function get_Jav_Code() {
		let video_title = document.querySelector('div#video_title a');
		return CODE_REG.TITLE.exec(video_title.innerText)[0]
	}
	function judge_Code(judge_id, score_obj_array) {
		for (let index = 0; index < score_obj_array.length; index++) {
			if (judge_id === score_obj_array[index].jav_code) {
				return index
			}
		}
		return -1
	}
	function judge_Name(name_value, name_obj_array) {
		return name_obj_array.indexOf(name_value) > -1
	}
	function judge_Color(score_value) {
		score_value = Number(score_value);
		switch (score_value) {
		case 1:
			return SCORE_COLOR.__1__;
		case 2:
			return SCORE_COLOR.__2__;
		case 3:
			return SCORE_COLOR.__3__;
		case 4:
			return SCORE_COLOR.__4__;
		case 5:
			return SCORE_COLOR.__5__;
		case 6:
			return SCORE_COLOR.__6__;
		case 7:
			return SCORE_COLOR.__7__;
		case 8:
			return SCORE_COLOR.__8__;
		case 9:
			return SCORE_COLOR.__9__;
		case 10:
		default:
			return SCORE_COLOR.__10__
		}
	}
	function add_Score_Tags(score_value) {
		let score_span = document.querySelector('span.score');
		score_span.after(create_Score_Span(score_value))
	}
	function add_Love_Tags(select_dom) {
		if (select_dom.parentNode.getElementsByClassName('alias').length > 0) {
			let alias = select_dom.parentNode.getElementsByClassName('alias');
			alias[alias.length - 1].after(FAVORITE_STRING)
		} else {
			select_dom.after(FAVORITE_STRING)
		}
	}
	function modify_Score_Tags(score_value) {
		let score_span = document.querySelector('span.scoreSpan');
		score_span.style.color = judge_Color(score_value);
		score_span.innerText = ' (' + score_value + ') '
	}
	function write_Score(code_value, score_value) {
		let judge_value = judge_Code(code_value, javlibrary_config.score_array);
		if (judge_value !== -1) {
			javlibrary_config.score_array[judge_value].user_score = score_value;
			modify_Score_Tags(score_value)
		} else {
			let temp_score_obj = {
				jav_code: code_value,
				user_score: score_value,
			};
			javlibrary_config.score_array.push(temp_score_obj);
			add_Score_Tags(score_value)
		}
		GM_setValue('my_jav_config', javlibrary_config)
	}
	function write_Actor(actor_value, actor_dom) {
		if (!judge_Name(actor_value, javlibrary_config.actor_array)) {
			javlibrary_config.actor_array.push(actor_value);
			if (actor_dom) {
				add_Love_Tags(actor_dom)
			}
		}
		GM_setValue('my_jav_config', javlibrary_config)
	}
	function write_Director(director_value, director_dom) {
		if (!judge_Name(director_value, javlibrary_config.director_array)) {
			javlibrary_config.director_array.push(director_value);
			if (director_dom) {
				add_Love_Tags(director_dom)
			}
		}
		GM_setValue('my_jav_config', javlibrary_config)
	}
	function write_Maker(maker_value, maker_dom) {
		if (!judge_Name(maker_value, javlibrary_config.maker_array)) {
			javlibrary_config.maker_array.push(maker_value);
			if (maker_dom) {
				add_Love_Tags(maker_dom)
			}
		}
		GM_setValue('my_jav_config', javlibrary_config)
	}
	function write_Label(label_value, label_dom) {
		if (!judge_Name(label_value, javlibrary_config.label_array)) {
			javlibrary_config.label_array.push(label_value);
			if (label_dom) {
				add_Love_Tags(label_dom)
			}
		}
		GM_setValue('my_jav_config', javlibrary_config)
	}
	function create_Score_Div(score_value) {
		let score_div = document.createElement('div');
		score_div.className = 'scoreDiv';
		score_div.style.fontSize = '13px';
		score_div.style.lineHeight = '20px';
		score_div.style.color = judge_Color(score_value);
		score_div.innerText = score_value;
		return score_div
	}
	function create_Score_Span(score_value) {
		let score_span = document.createElement('span');
		score_span.className = 'scoreSpan';
		score_span.style.color = judge_Color(score_value);
		score_span.innerText = ' (' + score_value + ') ';
		return score_span
	}
	function create_Nav_Td(nav_string, nav_width) {
		let nav_td = document.createElement('td');
		nav_td.className = 'navTd';
		nav_td.style.width = nav_width;
		nav_td.innerText = nav_string;
		return nav_td
	}
	function create_Score_Td(score_value) {
		let score_td = document.createElement('td');
		score_td.className = 'scoreTd';
		score_td.style.color = judge_Color(score_value);
		score_td.innerText = score_value;
		return score_td
	}
	function create_Extract_Button(extract_string, extract_code) {
		let extract_button = document.createElement('a');
		extract_button.className = 'extractButton';
		extract_button.href = 'javascript:;';
		extract_button.style.color = 'blue';
		extract_button.title = lang_value.button_text + extract_string;
		extract_button.innerText = ' ' + lang_value.button_text + extract_string;
		extract_button.addEventListener('click', function() {
			pick_Up_Function(extract_code)
		});
		return extract_button
	}
	function display_Info() {
		let jav_id = get_Jav_Code();
		if (jav_id) {
			let judge_value = judge_Code(jav_id, javlibrary_config.score_array);
			if (judge_value !== -1) {
				let jav_user_score = javlibrary_config.score_array[judge_value].user_score;
				add_Score_Tags(jav_user_score)
			}
			let star_rating = document.querySelectorAll('.star-rating.rater-0');
			star_rating.forEach(function(item, star_index) {
				item.addEventListener('click', function() {
					write_Score(jav_id, star_index + 1)
				})
			})
		}
		let actor_cast = document.querySelectorAll('span.cast');
		if (actor_cast) {
			for (let i = 0; i < actor_cast.length; i++) {
				let actor_name = actor_cast[i].getElementsByTagName('a')[0].innerText;
				if (judge_Name(actor_name, javlibrary_config.actor_array)) {
					add_Love_Tags(actor_cast[i].getElementsByClassName('star')[0])
				} else {
					actor_cast[i].getElementsByClassName('icn_favstar')[0].addEventListener('click', function() {
						write_Actor(actor_name, actor_cast[i].getElementsByClassName('star')[0])
					})
				}
			}
		}
		let director_span = document.querySelector('span.director');
		if (director_span) {
			let director_name = director_span.getElementsByTagName('a')[0].innerText;
			if (judge_Name(director_name, javlibrary_config.director_array)) {
				add_Love_Tags(director_span.getElementsByTagName('a')[0])
			} else {
				if (director_span.getElementsByClassName('icn_favdirector')[0]) {
					director_span.getElementsByClassName('icn_favdirector')[0].addEventListener('click', function() {
						write_Director(director_name, director_span.getElementsByTagName('a')[0])
					})
				}
			}
		}
		let maker_span = document.querySelector('span.maker');
		if (maker_span) {
			let maker_name = maker_span.getElementsByTagName('a')[0].innerText;
			if (judge_Name(maker_name, javlibrary_config.maker_array)) {
				add_Love_Tags(maker_span.getElementsByTagName('a')[0])
			} else {
				if (maker_span.getElementsByClassName('icn_favmaker')[0]) {
					maker_span.getElementsByClassName('icn_favmaker')[0].addEventListener('click', function() {
						write_Maker(maker_name, maker_span.getElementsByTagName('a')[0])
					})
				}
			}
		}
		let label_span = document.querySelector('span.label');
		if (label_span) {
			let label_name = label_span.getElementsByTagName('a')[0].innerText;
			if (judge_Name(label_name, javlibrary_config.label_array)) {
				add_Love_Tags(label_span.getElementsByTagName('a')[0])
			} else {
				if (label_span.getElementsByClassName('icn_favlabel')[0]) {
					label_span.getElementsByClassName('icn_favlabel')[0].addEventListener('click', function() {
						write_Label(label_name, label_span.getElementsByTagName('a')[0])
					})
				}
			}
		}
		convert_Time_Length()
	}
	function add_Div_For_Thumb(jav_video_a) {
		jav_video_a.forEach(function(item, index) {
			let judge_value = judge_Code(CODE_REG.TITLE.exec(item.title)[0], javlibrary_config.score_array);
			if (judge_value !== -1) {
				document.querySelectorAll('div.video')[index].appendChild(create_Score_Div(javlibrary_config.score_array[judge_value].user_score))
			}
		})
	}
	function add_Word_For_Text(jav_title) {
		document.querySelector('table.videotextlist tr.header').appendChild(create_Nav_Td(lang_value.score_string, '50px'));
		jav_title.forEach(function(item, index) {
			let jav_id = CODE_REG.TITLE.exec(item.title)[0];
			if (jav_id) {
				let judge_value = judge_Code(jav_id, javlibrary_config.score_array);
				if (judge_value !== -1) {
					document.querySelectorAll('table.videotextlist tr')[index + 1].appendChild(create_Score_Td(javlibrary_config.score_array[judge_value].user_score))
				} else {
					document.querySelectorAll('table.videotextlist tr')[index + 1].appendChild(create_Score_Td(''))
				}
			}
		})
	}
	function display_Index() {
		document.querySelector('div.videothumblist').style.height = 'auto';
		let post_headline_a = document.querySelectorAll('a.post-headline');
		add_Div_For_Thumb(post_headline_a)
	}
	function display_Mv_Rated(current_url) {
		if (DISPLAY_REG.THUMB.test(current_url)) {
			let jav_video_a = document.querySelectorAll('div.video a');
			add_Div_For_Thumb(jav_video_a)
		} else {
			document.querySelector('div.boxtitle').appendChild(create_Extract_Button(lang_value.score_string, 0));
			if (javlibrary_config.extract_value.extract_score) {
				pick_Up_Function(0)
			}
		}
	}
	function display_Mv_Commented(current_url) {
		if (DISPLAY_REG.THUMB.test(current_url)) {
			let jav_video_a = document.querySelectorAll('div.video a');
			add_Div_For_Thumb(jav_video_a)
		} else {
			let jav_title = document.querySelectorAll('td.title a');
			add_Word_For_Text(jav_title)
		}
	}
	function display_Mv_Visited(current_url) {
		if (DISPLAY_REG.LIST.test(current_url)) {
			let jav_title = document.querySelectorAll('td.title a');
			add_Word_For_Text(jav_title)
		} else {
			let jav_video_a = document.querySelectorAll('div.video a');
			add_Div_For_Thumb(jav_video_a)
		}
	}
	function display_Vl_Update(current_url) {
		if (DISPLAY_REG.LIST.test(current_url)) {
			let jav_title = document.querySelectorAll('div.video > a');
			add_Word_For_Text(jav_title)
		} else {
			let jav_video_a = document.querySelectorAll('div.video > a');
			add_Div_For_Thumb(jav_video_a)
		}
	}
	function display_Tl_Bestreviews() {
		let strong_a = document.querySelectorAll('table.comment strong a');
		strong_a.forEach(function(item, index) {
			let jav_id = CODE_REG.TITLE.exec(item.innerText)[0];
			if (jav_id) {
				let judge_value = judge_Code(jav_id, javlibrary_config.score_array);
				if (judge_value !== -1) {
					document.querySelectorAll('span.score')[index].after(create_Score_Span(javlibrary_config.score_array[judge_value].user_score))
				}
			}
		});
		convert_Time_Length_For_Tl_BestREVIEWS()
	}
	function display_Mv_Favdirectors(keyword) {
		switch (keyword) {
		case 1:
			document.querySelector('div.boxtitle').appendChild(create_Extract_Button(lang_value.director_string, 1));
			if (javlibrary_config.extract_value.extract_director) {
				pick_Up_Function(1)
			}
			break;
		case 2:
			document.querySelector('div.boxtitle').appendChild(create_Extract_Button(lang_value.maker_string, 2));
			if (javlibrary_config.extract_value.extract_maker) {
				pick_Up_Function(2)
			}
			break;
		case 3:
			document.querySelector('div.boxtitle').appendChild(create_Extract_Button(lang_value.label_string, 3));
			if (javlibrary_config.extract_value.extract_label) {
				pick_Up_Function(3)
			}
			break;
		case 4:
			document.querySelector('div.boxtitle').appendChild(create_Extract_Button(lang_value.actor_string, 4));
			if (javlibrary_config.extract_value.extract_actor) {
				pick_Up_Function(4)
			}
			break;
		default:
			console.log('error keyword!');
			break
		}
	}
	function calc_Hots() {
		let favorite = document.querySelectorAll('div#video_favorite_edit a');
		let total_num = 0;
		favorite.forEach(function(item, index) {
			total_num = total_num + parseInt(item.innerText)
		});
		let hots_span = document.createElement('span');
		hots_span.idName = 'hotsSpan';
		hots_span.setAttribute('style', 'margin-left: 20px; font-size: 13px; color: #999999;');
		hots_span.innerText = lang_value.hots_string;
		let hots_text_span = document.createElement('span');
		hots_text_span.idName = 'hotsTextSpan';
		if (total_num < 50) {
			hots_text_span.style.color = SCORE_COLOR.__1__
		} else if (total_num < 100) {
			hots_text_span.style.color = SCORE_COLOR.__2__
		} else if (total_num < 250) {
			hots_text_span.style.color = SCORE_COLOR.__3__
		} else if (total_num < 500) {
			hots_text_span.style.color = SCORE_COLOR.__4__
		} else if (total_num < 750) {
			hots_text_span.style.color = SCORE_COLOR.__5__
		} else if (total_num < 1000) {
			hots_text_span.style.color = SCORE_COLOR.__6__
		} else if (total_num < 2000) {
			hots_text_span.style.color = SCORE_COLOR.__7__
		} else if (total_num < 3500) {
			hots_text_span.style.color = SCORE_COLOR.__8__
		} else if (total_num < 5000) {
			hots_text_span.style.color = SCORE_COLOR.__9__
		} else {
			hots_text_span.style.color = SCORE_COLOR.__10__
		}
		hots_text_span.innerText = total_num.toString();
		hots_span.appendChild(hots_text_span);
		document.querySelector('div#video_favorite_edit').appendChild(hots_span)
	}
	function convert_Time_Length() {
		let time_span = document.querySelector('span.text');
		let time_length = parseInt(time_span.innerText);
		let time_hour = Math.floor(time_length / 60);
		if (time_hour > 0) {
			let time_min = time_length % 60;
			time_span.innerText = time_hour.toString() + lang_value.hour_string + time_min.toString()
		}
	}
	function convert_Time_Length_For_Tl_BestREVIEWS() {
		let videoinfo = document.querySelectorAll('table.videoinfo');
		videoinfo.forEach(function(item, index) {
			let time_td = item.querySelectorAll('tr td')[3];
			let time_length = parseInt(time_td.innerText);
			let time_hour = Math.floor(time_length / 60);
			if (time_hour > 0) {
				let time_min = time_length % 60;
				time_td.innerText = time_hour.toString() + lang_value.hour_string + time_min.toString() + lang_value.min_string
			}
		})
	}
	function pick_Up_Function(keyword) {
		switch (keyword) {
		case 0:
			if (!javlibrary_config.extract_value.extract_score) {
				javlibrary_config.extract_value.extract_score = true;
				GM_setValue('my_jav_config', javlibrary_config)
			}
			pick_Up_Score();
			break;
		case 1:
			if (!javlibrary_config.extract_value.extract_director) {
				javlibrary_config.extract_value.extract_director = true;
				GM_setValue('my_jav_config', javlibrary_config)
			}
			pick_Up_Director();
			break;
		case 2:
			if (!javlibrary_config.extract_value.extract_maker) {
				javlibrary_config.extract_value.extract_maker = true;
				GM_setValue('my_jav_config', javlibrary_config)
			}
			pick_Up_Maker();
			break;
		case 3:
			if (!javlibrary_config.extract_value.extract_label) {
				javlibrary_config.extract_value.extract_label = true;
				GM_setValue('my_jav_config', javlibrary_config)
			}
			pick_Up_Label();
			break;
		case 4:
			if (!javlibrary_config.extract_value.extract_actor) {
				javlibrary_config.extract_value.extract_actor = true;
				GM_setValue('my_jav_config', javlibrary_config)
			}
			pick_Up_Actor();
			break;
		default:
			console.log('error keyword!');
			break
		}
	}
	function pick_Up_Score() {
		let jav_title = document.querySelectorAll('td.title a');
		let write_status = false;
		document.querySelector('.extractButton').innerText = lang_value.extracting_string;
		for (let i = 0; i < jav_title.length; i++) {
			let jav_id = CODE_REG.TITLE.exec(jav_title[i].innerText)[0];
			let judge_value = judge_Code(jav_id, javlibrary_config.score_array);
			if (judge_value === -1) {
				let temp_score_obj = {
					jav_code: jav_id,
					user_score: document.querySelectorAll('td.score div')[i * 2].title,
				};
				javlibrary_config.score_array.push(temp_score_obj);
				write_status = true
			}
		}
		if (write_status) {
			GM_setValue('my_jav_config', javlibrary_config)
		}
		let next_button = document.querySelector('a.page.next');
		if (next_button) {
			next_button.click()
		} else {
			javlibrary_config.extract_value.extract_score = false;
			GM_setValue('my_jav_config', javlibrary_config);
			document.querySelector('.extractButton').innerText = lang_value.extract_completed_string
		}
	}
	function pick_Up_Director() {
		let director_a = document.querySelectorAll('span.star a');
		let write_status = false;
		document.querySelector('.extractButton').innerText = lang_value.extracting_string;
		for (let i = 0; i < director_a.length; i++) {
			let director_name = director_a[i].innerText;
			if (!judge_Name(director_name, javlibrary_config.director_array)) {
				javlibrary_config.director_array.push(director_name);
				write_status = true
			}
		}
		if (write_status) {
			GM_setValue('my_jav_config', javlibrary_config)
		}
		let next_button = document.querySelector('a.page.next');
		if (next_button) {
			next_button.click()
		} else {
			javlibrary_config.extract_value.extract_director = false;
			GM_setValue('my_jav_config', javlibrary_config);
			document.querySelector('.extractButton').innerText = lang_value.extract_completed_string
		}
	}
	function pick_Up_Maker() {
		let maker_a = document.querySelectorAll('span.star a');
		let write_status = false;
		document.querySelector('.extractButton').innerText = lang_value.extracting_string;
		for (let i = 0; i < maker_a.length; i++) {
			let maker_name = maker_a[i].innerText;
			if (!judge_Name(maker_name, javlibrary_config.maker_array)) {
				javlibrary_config.maker_array.push(maker_name);
				write_status = true
			}
		}
		if (write_status) {
			GM_setValue('my_jav_config', javlibrary_config)
		}
		let next_button = document.querySelector('a.page.next');
		if (next_button) {
			next_button.click()
		} else {
			javlibrary_config.extract_value.extract_maker = false;
			GM_setValue('my_jav_config', javlibrary_config);
			document.querySelector('.extractButton').innerText = lang_value.extract_completed_string
		}
	}
	function pick_Up_Label() {
		let label_a = document.querySelectorAll('span.star a');
		let write_status = false;
		document.querySelector('.extractButton').innerText = lang_value.extracting_string;
		for (let i = 0; i < label_a.length; i++) {
			let label_name = label_a[i].innerText;
			if (!judge_Name(label_name, javlibrary_config.label_array)) {
				javlibrary_config.label_array.push(label_name);
				write_status = true
			}
		}
		if (write_status) {
			GM_setValue('my_jav_config', javlibrary_config)
		}
		let next_button = document.querySelector('a.page.next');
		if (next_button) {
			next_button.click()
		} else {
			javlibrary_config.extract_value.extract_label = false;
			GM_setValue('my_jav_config', javlibrary_config);
			document.querySelector('.extractButton').innerText = lang_value.extract_completed_string
		}
	}
	function pick_Up_Actor() {
		let actor_a = document.querySelectorAll('span.star a');
		let write_status = false;
		document.querySelector('.extractButton').innerText = lang_value.extracting_string;
		for (let i = 0; i < actor_a.length; i++) {
			let actor_name = actor_a[i].innerText;
			if (!judge_Name(actor_name, javlibrary_config.actor_array)) {
				javlibrary_config.actor_array.push(actor_name);
				write_status = true
			}
		}
		if (write_status) {
			GM_setValue('my_jav_config', javlibrary_config)
		}
		let next_button = document.querySelector('a.page.next');
		if (next_button) {
			next_button.click()
		} else {
			javlibrary_config.extract_value.extract_actor = false;
			GM_setValue('my_jav_config', javlibrary_config);
			document.querySelector('.extractButton').innerText = lang_value.extract_completed_string
		}
	}
	function set_Language(lang_string) {
		switch (lang_string) {
		case 'zh-cn':
			lang_value = LANG.ZH_CN;
			break;
		case 'zh-tw':
			lang_value = LANG.ZH_TW;
			break;
		case 'en':
			lang_value = LANG.EN;
			break;
		case 'ja':
			lang_value = LANG.JA;
			break;
		default:
			lang_value = LANG.JA;
			break
		}
	}
	function init() {
		set_Language(document.getElementsByTagName('html')[0].lang);
		let old_url = location.href;
		document.getElementById('toplogo').style.height = '55px';
		if (JAV_REG.INDEX.test(old_url)) {
			display_Index()
		} else if (JAV_REG.VL_UPDATE.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_NEWRELEASE.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_NEWENTRIES.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_MOSTWANTED.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_BESTRATED.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_SEARCH.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_GENRE.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_STAR.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_DIRECTOR.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_MAKER.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.VL_LABEL.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.INFO.test(old_url)) {
			display_Info();
			calc_Hots()
		} else if (JAV_REG.MV_RATED.test(old_url)) {
			display_Mv_Rated(old_url)
		} else if (JAV_REG.MV_COMMENTED.test(old_url)) {
			display_Mv_Commented(old_url)
		} else if (JAV_REG.MV_WATCHED.test(old_url)) {
			display_Mv_Commented(old_url)
		} else if (JAV_REG.MV_OWNED.test(old_url)) {
			display_Mv_Commented(old_url)
		} else if (JAV_REG.MV_WANTED.test(old_url)) {
			display_Mv_Commented(old_url)
		} else if (JAV_REG.MV_VISITED.test(old_url)) {
			let observer = new MutationObserver(function() {
				display_Mv_Visited(old_url)
			});
			let listenerContainer = document.querySelector('div.videolist');
			let option = {
				'childList': true,
			};
			observer.observe(listenerContainer, option)
		} else if (JAV_REG.MV_FAVDIRECTORS.test(old_url)) {
			display_Mv_Favdirectors(1)
		} else if (JAV_REG.MV_FAVMAKERS.test(old_url)) {
			display_Mv_Favdirectors(2)
		} else if (JAV_REG.MV_FAVLABELS.test(old_url)) {
			display_Mv_Favdirectors(3)
		} else if (JAV_REG.MV_FAVSTARS.test(old_url)) {
			display_Mv_Favdirectors(4)
		} else if (JAV_REG.TL_BESTREVIEWS.test(old_url)) {
			display_Tl_Bestreviews()
		} else if (JAV_REG.VIDEOREVIEWS.test(old_url)) {
			display_Info()
		} else if (JAV_REG.VIDEOCOMMENTS.test(old_url)) {
			display_Info()
		} else if (JAV_REG.MYACCOUNT.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.USERPOSTS.test(old_url)) {
			display_Tl_Bestreviews()
		} else if (JAV_REG.USERWANTED.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.USERWATCHED.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.USEROWNED.test(old_url)) {
			display_Vl_Update(old_url)
		} else if (JAV_REG.USERSWANTED.test(old_url)) {
			display_Info()
		} else if (JAV_REG.USERSWATCHED.test(old_url)) {
			display_Info()
		} else if (JAV_REG.USERSOWNED.test(old_url)) {
			display_Info()
		}
	}
	Promise.all([GM_getValue('my_jav_config')]).then(function(data) {
		if (data[0] !== undefined) {
			javlibrary_config = data[0]
		} else {
			javlibrary_config = default_config
		}
		init()
	})
})();