Seletion is Back!

Get select & copy & right-click back on nogizaka/keyakizaka/hinatazaka official website

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Seletion is Back!
// @version      3.1
// @description  Get select & copy & right-click back on nogizaka/keyakizaka/hinatazaka official website
// @author       nondanee
// @match        *://*.keyakizaka46.com/*
// @match        *://*.nogizaka46.com/*
// @match        *://*.hinatazaka46.com/*
// @namespace https://greasyfork.org/users/160192
// ==/UserScript==

(() => {
	'use strict'
	let styleSheet = Array.from(document.styleSheets).filter(styleSheet => !styleSheet.href)[0]
	if(window.location.href.includes('nogizaka')){
		document.body.oncontextmenu = null
		styleSheet.insertRule('::selection{background: rgba(126, 16, 131, 0.9); color: #ffffff}', 0)
	}
	else if(['keyakizaka', 'hinatazaka'].some(key => window.location.href.includes(key))){
		if(window.location.href.includes('keyakizaka')) styleSheet.insertRule('::selection{background: rgba(160, 212, 104, 0.9); color: #ffffff}', 0)
		Array.from(document.getElementsByTagName('img')).forEach(element => ['onmousedown', 'onselectstart', 'oncontextmenu'].forEach(event => element.setAttribute(event, '')))
		let inlineStyle = Array.from(document.getElementsByTagName('style')).find(element => element.innerHTML.includes('user-select'))
		if(inlineStyle) inlineStyle.parentNode.removeChild(inlineStyle)
	}
})()