Instagram - 為使用者新增備註

為使用者新增備註功能,以幫助識別和搜尋

目前為 2020-04-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name                Instagram为关注用户添加备注
// @name:en             Instagram - Add a note to the user
// @name:zh-CN          Instagram - 为用户添加备注
// @name:zh-TW          Instagram - 為使用者新增備註
// @name:ja             Instagram - ユーザーに備考を加える
// @name:ko             Instagram - 사용자에 대한 주석 추가
// @namespace           https://greasyfork.org/zh-CN/users/193133-pana
// @homepage            https://www.sailboatweb.com
// @icon                data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMCwxNSBMMjAsNCBMNCw0IEw0LDIwIEwxNSwyMCBMMTUsMTcgQzE1LDE1Ljg5NTQzMDUgMTUuODk1NDMwNSwxNSAxNywxNSBMMjAsMTUgWiBNMTkuNTg1Nzg2NCwxNyBMMTcsMTcgTDE3LDE5LjU4NTc4NjQgTDE5LjU4NTc4NjQsMTcgWiBNNCwyMiBDMi44OTU0MzA1LDIyIDIsMjEuMTA0NTY5NSAyLDIwIEwyLDQgQzIsMi44OTU0MzA1IDIuODk1NDMwNSwyIDQsMiBMMjAsMiBDMjEuMTA0NTY5NSwyIDIyLDIuODk1NDMwNSAyMiw0IEwyMiwxNy40MTQyMTM2IEwxNy40MTQyMTM2LDIyIEw0LDIyIFogTTcsMTcgTDcsMTUgTDEzLDE1IEwxMywxNyBMNywxNyBaIE03LDEzIEw3LDExIEwxNywxMSBMMTcsMTMgTDcsMTMgWiBNNyw5IEw3LDcgTDE3LDcgTDE3LDkgTDcsOSBaIi8+Cjwvc3ZnPgo=
// @version             2.0.2
// @description         为用户添加备注功能,以帮助识别和搜索
// @description:en      Add a note for users to help identify and search
// @description:zh-CN   为用户添加备注功能,以帮助识别和搜索
// @description:zh-TW   為使用者新增備註功能,以幫助識別和搜尋
// @description:ja      ユーザーに備考機能を追加し、識別と検索を助ける
// @description:ko      식별 및 검색에 도움이 되는 사용자에 대한 주석 추가 기능
// @author              pana
// @include             http*://www.instagram.com/*
// @require             https://code.jquery.com/jquery-3.4.1.min.js
// @require             https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.min.js
// @grant               GM_getValue
// @grant               GM_setValue
// ==/UserScript==

(function() {
	'use strict';
	const LANG = {
		ZH: {
			div_title: '备注',
			input_placeholder: '(请输入备注,置空时删除;按下Enter键保存)',
			save_button_text: '保存',
			clear_button_text: '清除',
			cancel_button_text: '取消',
			search_placeholder: '搜索备注',
		},
		ZH_TW: {
			div_title: '備註',
			input_placeholder: '(請輸入備註,置空時刪除;按下Enter鍵儲存)',
			save_button_text: '儲存',
			clear_button_text: '清除',
			cancel_button_text: '取消',
			search_placeholder: '搜尋備註',
		},
		EN: {
			div_title: 'Note',
			input_placeholder: '(Enter a note, delete it when blanked; press Enter to save)',
			save_button_text: 'Save',
			clear_button_text: 'Clear',
			cancel_button_text: 'Cancel',
			search_placeholder: 'Search notes',
		},
		JA: {
			div_title: '備考',
			input_placeholder: '(注を入力して、空にした時に削除してください。)',
			save_button_text: '保存する',
			clear_button_text: 'クリア',
			cancel_button_text: 'キャンセル',
			search_placeholder: '検索備考',
		},
		KO: {
			div_title: '주석',
			input_placeholder: '(메모를 입력하십시오. 비어 있을 때 삭제하십시오. )',
			save_button_text: '보존',
			clear_button_text: '제거',
			cancel_button_text: '취소',
			search_placeholder: '검색 노트',
		},
	};
	var lang_value = {
		div_title: 'Note',
		input_placeholder: '(Enter a note, delete it when blanked; press Enter to save)',
		save_button_text: 'Save',
		clear_button_text: 'Clear',
		cancel_button_text: 'Cancel',
		search_placeholder: 'Search notes',
	};
	var instagram_config = {
		user_array: [],
	};
	var show_list = [];
	const PAGE_REG = {
		HOMEPAGE: /^https?:\/\/www\.instagram\.com\/?(\?[a-z]+=[a-z-]+)?$/i,
		USER_PAGE: /^https?:\/\/www\.instagram\.com\/[^/]*\/?(\?[a-z]+=[a-z-]+)?$/i,
		STORIES: /^https?:\/\/www\.instagram\.com\/stories\/[^/]*\/?(\?[a-z]+=[a-z-]+)?$/i,
	};
	const ICON = {
		TAGS: 'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMCwxNSBMMjAsNCBMNCw0IEw0LDIwIEwxNSwyMCBMMTUsMTcgQzE1LDE1Ljg5NTQzMDUgMTUuODk1NDMwNSwxNSAxNywxNSBMMjAsMTUgWiBNMTkuNTg1Nzg2NCwxNyBMMTcsMTcgTDE3LDE5LjU4NTc4NjQgTDE5LjU4NTc4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iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0OTIuMDAyIDQ5Mi4wMDIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5Mi4wMDIgNDkyLjAwMjsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8Zz4KCTxnPgoJCTxwYXRoIGQ9Ik00ODQuMTM2LDMyOC40NzNMMjY0Ljk4OCwxMDkuMzI5Yy01LjA2NC01LjA2NC0xMS44MTYtNy44NDQtMTkuMTcyLTcuODQ0Yy03LjIwOCwwLTEzLjk2NCwyLjc4LTE5LjAyLDcuODQ0ICAgIEw3Ljg1MiwzMjguMjY1QzIuNzg4LDMzMy4zMzMsMCwzNDAuMDg5LDAsMzQ3LjI5N2MwLDcuMjA4LDIuNzg0LDEzLjk2OCw3Ljg1MiwxOS4wMzJsMTYuMTI0LDE2LjEyNCAgICBjNS4wNjQsNS4wNjQsMTEuODI0LDcuODYsMTkuMDMyLDcuODZzMTMuOTY0LTIuNzk2LDE5LjAzMi03Ljg2bDE4My44NTItMTgzLjg1MmwxODQuMDU2LDE4NC4wNjQgICAgYzUuMDY0LDUuMDYsMTEuODIsNy44NTIsMTkuMDMyLDcuODUyYzcuMjA4LDAsMTMuOTYtMi43OTIsMTkuMDI4LTcuODUybDE2LjEyOC0xNi4xMzIgICAgQzQ5NC42MjQsMzU2LjA0MSw0OTQuNjI0LDMzOC45NjUsNDg0LjEzNiwzMjguNDczeiIvPgoJPC9nPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+Cjwvc3ZnPgo=)',
	};

	function judge_User(user_title) {
		for (let i = 0; i < instagram_config.user_array.length; i++) {
			if (user_title === instagram_config.user_array[i].user_id) {
				return i
			}
		}
		return -1
	}
	function write_User(user_title, input_tag) {
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			if (input_tag) {
				instagram_config.user_array[judge_value].user_tag = input_tag
			} else {
				instagram_config.user_array.splice(judge_value, 1)
			}
		} else {
			if (input_tag) {
				let temp_user_obj = {
					user_id: user_title,
					user_tag: input_tag,
				};
				instagram_config.user_array.push(temp_user_obj)
			}
		}
		GM_setValue('instagram_config', instagram_config)
	}
	function create_Add_Input_Div(user_title) {
		let presentation_div = document.createElement('div');
		presentation_div.className = 'presentation_div_for_user';
		presentation_div.style.display = 'flex';
		presentation_div.style.position = 'fixed';
		presentation_div.style.backgroundColor = 'rgba(0, 0, 0, .5)';
		presentation_div.style.top = '0';
		presentation_div.style.bottom = '0';
		presentation_div.style.left = '0';
		presentation_div.style.right = '0';
		presentation_div.style.zIndex = '1';
		presentation_div.style.alignItems = 'center';
		presentation_div.style.justifyContent = 'center';
		presentation_div.addEventListener('click', function(event) {
			if (event.target === this) {
				$('.presentation_div_for_user').remove()
			}
		});
		let dialog_div = document.createElement('div');
		dialog_div.className = 'dialog_div_for_user';
		dialog_div.style.position = 'relative';
		dialog_div.style.width = '400px';
		dialog_div.style.backgroundColor = '#fff';
		dialog_div.style.border = '0 solid #000';
		dialog_div.style.borderRadius = '12px';
		let user_title_p = document.createElement('button');
		user_title_p.className = 'user_title_span_for_user';
		user_title_p.innerText = user_title;
		user_title_p.style.minHeight = '48px';
		user_title_p.style.textAlign = 'center';
		user_title_p.style.border = '1px solid #efefef';
		user_title_p.style.color = '#003399';
		user_title_p.style.fontWeight = 'bold';
		user_title_p.style.backgroundColor = 'rgba(0, 0, 0, 0)';
		user_title_p.style.borderTopLeftRadius = '12px';
		user_title_p.style.borderTopRightRadius = '12px';
		let tag_input = document.createElement('input');
		tag_input.className = 'tag_input_for_user';
		tag_input.type = 'text';
		tag_input.placeholder = lang_value.input_placeholder;
		tag_input.style.minHeight = '32px';
		tag_input.style.margin = '5px';
		tag_input.style.border = "1px solid #cc6666";
		tag_input.style.borderRadius = '3px';
		tag_input.style.paddingLeft = '5px';
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			tag_input.value = instagram_config.user_array[judge_value].user_tag
		} else {
			tag_input.value = ''
		}
		$(tag_input).keyup(function(e) {
			if (e.keyCode === 13) {
				write_User(user_title, $('.tag_input_for_user').val());
				save_Update_Event(user_title);
				$('.presentation_div_for_user').remove()
			}
		});
		setTimeout(function() {
			try {
				tag_input.focus();
				tag_input.select()
			} catch (e) {
				console.log(e)
			}
		}, 200);
		let save_button = document.createElement('button');
		save_button.className = 'save_button_for_user';
		save_button.type = 'button';
		save_button.innerText = lang_value.save_button_text;
		save_button.style.minHeight = '48px';
		save_button.style.cursor = 'pointer';
		save_button.style.border = '1px solid #efefef';
		save_button.style.backgroundColor = 'rgba(0, 0, 0, 0)';
		save_button.addEventListener('click', function() {
			write_User(user_title, $('.tag_input_for_user').val());
			save_Update_Event(user_title);
			$('.presentation_div_for_user').remove()
		});
		let clear_button = document.createElement('button');
		clear_button.className = 'clear_button_for_user';
		clear_button.type = 'button';
		clear_button.innerText = lang_value.clear_button_text;
		clear_button.style.minHeight = '48px';
		clear_button.style.cursor = 'pointer';
		clear_button.style.border = '1px solid #efefef';
		clear_button.style.backgroundColor = 'rgba(0, 0, 0, 0)';
		clear_button.addEventListener('click', function() {
			write_User(user_title, '');
			save_Update_Event(user_title);
			$('.presentation_div_for_user').remove()
		});
		let cancel_button = document.createElement('button');
		cancel_button.className = 'cancel_button_for_user';
		cancel_button.type = 'button';
		cancel_button.innerText = lang_value.cancel_button_text;
		cancel_button.style.minHeight = '48px';
		cancel_button.style.cursor = 'pointer';
		cancel_button.style.border = '1px solid #efefef';
		cancel_button.style.backgroundColor = 'rgba(0, 0, 0, 0)';
		cancel_button.style.borderBottomLeftRadius = '12px';
		cancel_button.style.borderBottomRightRadius = '12px';
		cancel_button.addEventListener('click', function(_event) {
			$('.presentation_div_for_user').remove()
		});
		dialog_div.appendChild(user_title_p);
		dialog_div.appendChild(tag_input);
		dialog_div.appendChild(save_button);
		dialog_div.appendChild(clear_button);
		dialog_div.appendChild(cancel_button);
		presentation_div.appendChild(dialog_div);
		return presentation_div
	}
	function create_Add_Tags_Div(user_title, icon_size, margin_top) {
		let tags_div = document.createElement('div');
		tags_div.className = 'Tags_A';
		tags_div.title = lang_value.div_title;
		tags_div.style.width = icon_size;
		tags_div.style.height = icon_size;
		tags_div.style.backgroundImage = ICON.TAGS;
		tags_div.style.backgroundRepeat = 'no-repeat';
		tags_div.style.backgroundPosition = 'center';
		tags_div.style.backgroundSize = icon_size;
		tags_div.style.marginLeft = '5px';
		tags_div.style.cursor = 'pointer';
		tags_div.style.marginTop = margin_top;
		tags_div.addEventListener('click', function() {
			document.body.appendChild(create_Add_Input_Div(user_title))
		});
		return tags_div
	}
	function create_Add_Tag_P(tag_string) {
		let tag_p = document.createElement('p');
		tag_p.className = 'tag_p';
		tag_p.style.marginLeft = '5px';
		tag_p.style.color = '#336699';
		tag_p.style.whiteSpace = 'nowrap';
		tag_p.innerText = '[' + tag_string + ']';
		return tag_p
	}
	function create_Add_Tag_Span(tag_string, font_size) {
		let tag_span = document.createElement('span');
		tag_span.className = 'tag_span';
		tag_span.style.marginLeft = '5px';
		tag_span.style.color = '#336699';
		tag_span.style.fontSize = font_size;
		tag_span.innerText = '[' + tag_string + ']';
		return tag_span
	}
	function create_List_Div(id_number, user_obj) {
		let list_div = document.createElement('div');
		list_div.id = 'tags_' + id_number;
		list_div.innerText = user_obj.user_tag;
		list_div.style.cursor = 'pointer';
		$(list_div).mouseenter(function() {
			$(this).css('background-color', '#6699CC').siblings().css('background-color', '')
		});
		$(list_div).on('click', function() {
			window.location.href = 'https://www.instagram.com/' + user_obj.user_id + '/'
		});
		return list_div
	}
	function create_Search_Frame() {
		let search_frame = document.createElement('div');
		search_frame.id = 'searchFrame';
		search_frame.style.position = 'relative';
		search_frame.style.marginLeft = '15px';
		let search_input = document.createElement('input');
		search_input.id = 'myInputSearch';
		search_input.type = 'text';
		search_input.placeholder = lang_value.search_placeholder;
		search_input.value = "";
		search_input.style.width = '200px';
		search_input.style.height = '25px';
		search_input.style.border = '1px solid #999';
		search_input.style.borderRadius = '3px';
		search_input.style.padding = '0 3px';
		search_input.style.position = 'relative';
		$(search_input).focus(function() {
			$('#tagsList').show();
			let arrow = $('.dropDowns');
			arrow.addClass('up_arrow');
			if (arrow.hasClass('up_arrow')) {
				arrow.css('background-image', ICON.UP_ARROW)
			} else {
				arrow.css('background-image', ICON.DOWN_ARROW)
			}
			search_Event(search_input)
		});
		search_frame.appendChild(search_input);
		let dropdowns = document.createElement('div');
		dropdowns.className = 'picture_click dropDowns';
		dropdowns.style.width = '15px';
		dropdowns.style.height = '15px';
		dropdowns.style.backgroundImage = ICON.DOWN_ARROW;
		dropdowns.style.backgroundRepeat = 'no-repeat';
		dropdowns.style.backgroundSize = '12px auto';
		dropdowns.style.position = 'absolute';
		dropdowns.style.top = '8px';
		dropdowns.style.right = '2px';
		$(dropdowns).click(function() {
			$(this).parent().find('.selectList').toggle();
			$(this).toggleClass('up_arrow');
			if ($(this).hasClass('up_arrow')) {
				$(this).css('background-image', ICON.UP_ARROW)
			} else {
				$(this).css('background-image', ICON.DOWN_ARROW)
			}
		});
		search_frame.appendChild(dropdowns);
		let tags_list = document.createElement('div');
		tags_list.id = 'tagsList';
		tags_list.className = 'selectList';
		tags_list.style.width = '208px';
		tags_list.style.height = '218px';
		tags_list.style.overflowY = 'scroll';
		tags_list.style.textAlign = 'left';
		tags_list.style.border = '1px solid #999';
		tags_list.style.display = 'none';
		tags_list.style.position = 'absolute';
		tags_list.style.top = '27px';
		tags_list.style.backgroundColor = '#fff';
		$.each(instagram_config.user_array, function(index, item) {
			tags_list.appendChild(create_List_Div(index, item))
		});
		search_frame.appendChild(tags_list);
		document.body.onclick = function(e) {
			e = e || window.event;
			let target = e.target || e.srcElement;
			if (target !== $('.dropDowns')[0] && target !== $('.selectList')[0] && target !== $('#myInputSearch')[0]) {
				$('#tagsList').hide();
				let arrow = $('.dropDowns');
				arrow.removeClass('up_arrow');
				if (arrow.hasClass('up_arrow')) {
					arrow.css('background-image', ICON.UP_ARROW)
				} else {
					arrow.css('background-image', ICON.DOWN_ARROW)
				}
			}
		};
		return search_frame
	}
	function search_Event(input_dom) {
		let list_arr = [];
		$.each($('#tagsList div'), function(index, item) {
			let arr_obj = {
				ele_container: item.innerText,
				ele: item,
			};
			list_arr.push(arr_obj)
		});
		let current_index = 0;
		$(input_dom).keyup(function(event) {
			$('#tagsList').show();
			let arrow = $('.dropDowns');
			arrow.addClass('up_arrow');
			if (arrow.hasClass('up_arrow')) {
				arrow.css('background-image', ICON.UP_ARROW)
			} else {
				arrow.css('background-image', ICON.DOWN_ARROW)
			}
			if (event.keyCode === 38) {
				event.returnValue = false
			} else if (event.keyCode === 40) {
				event.returnValue = false
			} else if (event.keyCode === 37) {
				event.returnValue = false
			} else if (event.keyCode === 39) {
				event.returnValue = false
			} else if (event.keyCode === 13) {
				$(show_list[current_index]).click()
			} else {
				let search_val = $(this).val();
				show_list = [];
				$.each(list_arr, function(index, item) {
					if (item.ele_container.indexOf(search_val) !== -1) {
						item.ele.style.display = 'block';
						show_list.push(item.ele)
					} else {
						item.ele.style.display = 'none'
					}
				});
				current_index = 0
			}
			$.each(show_list, function(index, item) {
				if (index === current_index) {
					item.style.backgroundColor = '#6699CC';
					$('#tagsList').scrollTop(item.offsetTop)
				} else {
					item.style.backgroundColor = ''
				}
			});
			let list_height = $('#tagsList div:first').height() * show_list.length;
			if (list_height < 218) {
				$('#tagsList').height(list_height)
			} else {
				$('#tagsList').height(218)
			}
		});
		$(input_dom).keydown(function(event) {
			if (event.keyCode === 38) {
				current_index--;
				if (current_index < 0) {
					current_index = 0
				}
			} else if (event.keyCode === 40) {
				current_index++;
				if (current_index >= show_list.length) {
					current_index = show_list.length - 1
				}
			}
			$.each(show_list, function(index, item) {
				if (index === current_index) {
					item.style.backgroundColor = '#6699CC';
					$('#tagsList').scrollTop(item.offsetTop)
				} else {
					item.style.backgroundColor = ''
				}
			})
		})
	}
	function homepage_Event(dom_container) {
		let user_title = $(dom_container).find('div.e1e1d a').text();
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			$(dom_container).find('.e1e1d').append(create_Add_Tag_P(instagram_config.user_array[judge_value].user_tag))
		}
		$(dom_container).find('span.wmtNn').before(create_Add_Tags_Div(user_title, '24px', '8px'));
		$(dom_container).find('.e1e1d').css('overflow', 'visible')
	}
	function homepage_Stories_Event(dom_container) {
		let user_title = $(dom_container).find('.jQgLo').text();
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			$(dom_container).find('.jQgLo').append(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '12px'))
		}
	}
	function user_Page_Event(selector_container) {
		let user_title = selector_container.find('.KV-D4').text();
		selector_container.find('.AFWDX').after(create_Add_Tags_Div(user_title, '18px', '2px'));
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			selector_container.find('.AFWDX').after(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '16px'))
		}
		$.each(selector_container.find('span._32eiM'), function(index, item) {
			let em_user_title = item.innerText;
			let em_judge_value = judge_User(em_user_title);
			if (em_judge_value !== -1) {
				item.innerText = em_user_title + ' [' + instagram_config.user_array[em_judge_value].user_tag + ']'
			}
		})
	}
	function stories_Page_Event(selector_container) {
		let user_title = selector_container.find('.FPmhX').text();
		let judge_value = judge_User(user_title);
		if (judge_value !== -1) {
			selector_container.append(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '14px'))
		}
	}
	function follow_Page_Event(selector_container) {
		if (selector_container.find('.tag_span').length === 0) {
			let user_title = selector_container.find('a.FPmhX').attr('title');
			let judge_value = judge_User(user_title);
			if (judge_value !== -1) {
				selector_container.find('a.FPmhX').parent().append(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '14px'))
			}
		}
	}
	function save_Update_Event(user_title) {
		let old_url = location.href;
		if (PAGE_REG.HOMEPAGE.test(old_url)) {
			$.each($('article'), function(_index, item) {
				let page_user_title = $(item).find('div.e1e1d a').text();
				if (user_title === page_user_title) {
					let judge_value = judge_User(user_title);
					if (judge_value !== -1) {
						if ($(item).find('p.tag_p').length !== 0) {
							$(item).find('p.tag_p').text('[' + instagram_config.user_array[judge_value].user_tag + ']')
						} else {
							$(item).find('.Tags_A').before(create_Add_Tag_P(instagram_config.user_array[judge_value].user_tag))
						}
					} else {
						if ($(item).find('p.tag_p').length !== 0) {
							$(item).find('p.tag_p').remove()
						}
					}
				}
			});
			$.each($('.BI5t6'), function(index, item) {
				let page_user_selector = $(item).find('.jQgLo').clone();
				page_user_selector.find('.tag_span').remove();
				let page_user_title = page_user_selector.text();
				if (user_title === page_user_title) {
					let judge_value = judge_User(user_title);
					if (judge_value !== -1) {
						if ($(item).find('span.tag_span').length !== 0) {
							$(item).find('span.tag_span').text('[' + instagram_config.user_array[judge_value].user_tag + ']')
						} else {
							$(item).find('.jQgLo').append(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '12px'))
						}
					} else {
						if ($(item).find('span.tag_span').length !== 0) {
							$(item).find('span.tag_span').remove()
						}
					}
				}
			})
		} else if (PAGE_REG.USER_PAGE.test(old_url)) {
			let user_title = $('.KV-D4').text();
			let judge_value = judge_User(user_title);
			if (judge_value !== -1) {
				if ($('.tag_span').length !== 0) {
					$('.tag_span').text('[' + instagram_config.user_array[judge_value].user_tag + ']')
				} else {
					$('.AFWDX').after(create_Add_Tag_Span(instagram_config.user_array[judge_value].user_tag, '16px'))
				}
			} else {
				if ($('.tag_span').length !== 0) {
					$('.tag_span').remove()
				}
			}
		}
	}
	function set_Language(lang_string) {
		switch (lang_string) {
		case 'zh':
		case 'zh-cn':
			lang_value = LANG.ZH;
			break;
		case 'zh-hk':
		case 'zh-tw':
			lang_value = LANG.ZH_TW;
			break;
		case 'en':
			lang_value = LANG.EN;
			break;
		case 'ja':
			lang_value = LANG.JA;
			break;
		case 'ko':
			lang_value = LANG.KO;
			break;
		default:
			lang_value = LANG.EN;
			break
		}
		instagram_config.lang_value = lang_value;
		GM_setValue('instagram_config', instagram_config)
	}
	function init() {
		if (instagram_config.lang_value) {
			lang_value = instagram_config.lang_value
		} else {
			set_Language($('html:first').attr('lang'))
		}
		$('.LWmhU').after(create_Search_Frame());
		$('#react-root').arrive('.LWmhU', function() {
			$(this).after(create_Search_Frame())
		});
		$.each($('article'), function(_index, item) {
			homepage_Event(item)
		});
		setTimeout(function() {
			$.each($('.BI5t6'), function(_index, item) {
				homepage_Stories_Event(item)
			})
		}, 1000);
		$('#react-root').arrive('article', function() {
			homepage_Event(this)
		});
		$('#react-root').arrive('.BI5t6', function() {
			homepage_Stories_Event(this)
		});
		if ($('.zwlfE').length !== 0) {
			user_Page_Event($('.zwlfE'))
		}
		$('#react-root').arrive('.zwlfE', function() {
			user_Page_Event($(this))
		});
		if ($('.yn6BW').length !== 0) {
			stories_Page_Event($('.yn6BW'))
		}
		$('#react-root').arrive('.yn6BW', function() {
			stories_Page_Event($(this))
		});
		$('body').arrive('.isgrP li', {
			onceOnly: true
		}, function() {
			follow_Page_Event($(this))
		});
		$('body').arrive('.d7ByH', function() {
			follow_Page_Event($(this))
		})
	}
	Promise.all([GM_getValue('instagram_config')]).then(function(data) {
		if (data[0] !== undefined) {
			instagram_config = data[0]
		}
		init()
	})
})();