// https://developers.google.com/web/updates/2015/04/cut-and-copy-commands?hl=en
function copyStuff(button, output) {
	let range = document.createRange();
	range.selectNode(output);
	window.getSelection().addRange(range);

	try {
		// Now that we've selected the anchor text, execute the copy command
		const copy = document.execCommand('copy');
		log((copy ? '✅' : '❌'));
	} catch (err) {
		log('❌');
	}

	function log(text) {
		const old = button.textContent;
		button.textContent = text;
		setTimeout(() => {
			button.textContent = old;
		}, 2000);
	}
}

/**
 * Adds copyable input for an url
 * @param content the content to copy (location.href for example)
 * @param selector where to append the input and button
 */
export function addCopy(content, selector) {
	const copyBtn = document.createElement('button');
	const textInput = document.createElement('input');
	const container = document.querySelector(selector);

	textInput.value = content;
	textInput.disabled = true;
	copyBtn.textContent = '🔗';

	copyBtn.className = 'social--copy';

	copyBtn.disabled = !document.queryCommandSupported('copy');
	copyBtn.addEventListener('click', () => {
		copyStuff(copyBtn, textInput);
	});

	textInput.addEventListener('click', (e) => {
		e.target.select();
	});

	container.appendChild(textInput);
	container.appendChild(copyBtn);
}

@@ -855,21 +855,19 @@
 lement('
-input
+div
 ');%0A%09con
@@ -931,81 +931,97 @@
 put.
-value = content;%0A%09textInput.disabled = true;%0A%09copyBtn.textContent = '%F0%9F%94%97';%0A
+textContent = content;%0A%09copyBtn.textContent = '%F0%9F%94%97';%0A%0A%09textInput.className = 'social--url';
 %0A%09co
@@ -1239,35 +1239,128 @@
 k', 
-(e) =%3E %7B%0A%09%09e.target.select(
+function() %7B%0A%09%09let range = document.createRange();%0A%09%09range.selectNode(textInput);%0A%09%09window.getSelection().addRange(range
 );%0A%09

make a div instead of an input