url_clip

url clip

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         url_clip
// @include      *
// @supportURL   https://github.com/sxlgkxk/browser_script/issues
// @version      0.1
// @description  url clip
// @namespace    http://sxlgkxk.github.io/
// @author       sxlgkxk
// @icon         http://sxlgkxk.github.io/im/avatar.jpg
// @license      MIT
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function () {
	setTimeout(function () {
		// hexo url
		dom = document.createElement('div');
		dom.id = 'url-hexo-container';
		let title='', imageUrl='';
		title = document.title.replace('"', "'");
		console.log(`\n\n{%url ${location.href} "${title}" %}\n{%endurl%}`);

		if(location.href.startsWith('https://www.bilibili.com/')) {
			imageUrl=document.querySelector('head > meta[itemprop="thumbnailUrl"]').getAttribute('content')
			document.body.prepend(dom);
		}else if(location.href.startsWith('https://www.youtube.com/watch?v=')) {
			imageUrl=document.querySelector('head > meta[property="og:image"]').getAttribute('content')
			container=document.querySelector('#info-contents > ytd-video-primary-info-renderer');
			container.prepend(dom);
		}else if(location.href.startsWith('https://en.wikipedia.org')) {
			document.querySelector('#firstHeading').prepend(dom);
		} else {
			document.body.prepend(dom);
		}

		dom.innerHTML = `<button id="urltag_hide">hide</button><br><span>{%url ${location.href} "${title}" %}</span><br>`
		if(imageUrl)
			dom.innerHTML+=`<span>${imageUrl}</span><br>`
		dom.innerHTML+=`<span>{%endurl%}</span>
			<style>
				#url-hexo-container {
					text-align: center;
					background-color: #000;
					color: #ddd;
					padding: 10px;
					font-size: 20px;
					text-shadow: none;
					z-index: 999999;
					position: relative;
				}
			</style>
		`

		// add event to #urltag_hide : document.querySelector('#url-hexo-container').hidden=true
		document.querySelector('#urltag_hide').addEventListener('click', function () {
			document.querySelector('#url-hexo-container').hidden = true;
		})

	}, 1000*2)

})();