Zerochan List Links

Adds a button to copy all the image links on a page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name		Zerochan List Links
// @namespace	zerochan_list_links
// @description	Adds a button to copy all the image links on a page
// @homepageURL	https://github.com/namiman/zerochan_list_links
// @author		namiman
// @version		1.0
// @date		2018-02-11
// @include		https://www.zerochan.net/*
// @require		https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js
// ==/UserScript==

(function(){

	let links = [];
	
	function addStyles() {
		let head = document.getElementsByTagName( "head" )[0];
		let styles = document.createElement( "style" );
			styles.textContent =
			'.zerochan_list_links_textbox {'+
			'	min-width: 346px;'+
			'	min-height: 140px;'+
			'}'+
			'#zerochan_list_links_copy {'+
			'	cursor: pointer;'+
			'}';
			styles.id = "zerochan_list_links_styles";
		head.appendChild( styles );
	}

	function getLinks() {
		let items = document.getElementById( "thumbs2" ).getElementsByTagName( "li" );
		[].forEach.call( items, ( item ) => {
			links.push( item.getElementsByTagName( "p" )[0].getElementsByTagName( "a" )[1].href );
		});
	}
/*
	function displayLinks() {
		let menu = document.getElementById( "menu" );
		let textbox = document.createElement( "textarea" );
			textbox.textContent = links.join( "\n" );
			textbox.className = "zerochan_list_links_textbox";
		menu.appendChild( textbox );
	}
*/
	function createCopyButton() {

		let parent = document.getElementsByClassName( "browsing-options" )[0];
		let br = document.createElement( "br" );
		let button = document.createElement( "a" );
			button.textContent = "Copy Image Links";
			button.id = "zerochan_list_links_copy";
		parent.appendChild( br );
		parent.appendChild( button );

		new Clipboard( "#zerochan_list_links_copy", {
			text: function() {
				return links.join( "\n" );
			}
		});
	}

	addStyles();
	getLinks();
//	displayLinks();
	createCopyButton();

})();