Youtube: strip https from share url

Strip https from share url: youtu.be/xxxxyyyy

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Youtube: strip https from share url
// @description  Strip https from share url: youtu.be/xxxxyyyy
// @include      https://www.youtube.com/*
// @version      1.0
// @author       wOxxOm
// @namespace    https://greasyfork.org/users/2159-woxxom
// @license      MIT License
// @run-at       document-end
// ==/UserScript==

window.addEventListener('load', waitForShare);
window.addEventListener('spfdone', waitForShare);
						
function waitForShare() {
	var panel = document.getElementById('watch-actions-share-panel');
	if (!panel)
		return;
	
	new MutationObserver(function(mutations) {
		this.disconnect();
		
		var input = panel.querySelector('[value*="//youtu.be"]');
		if (!input)
			return;
		
		stripProtocol();
		input.addEventListener('focus', stripProtocol);

		function stripProtocol() {
			input.value = input.value.replace(/https?:\/\//, '');
			input.select();
		}
	}).observe(panel, {subtree: true, childList: true});
}