cutt.ly URL shorten button

set a URL-shorten button at the bottom left corner. It will create a new window for the shortened URL of cutt.ly.

Versione datata 20/04/2020. Vedi la nuova versione l'ultima versione.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo 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		cutt.ly URL shorten button
// @name:zh-TW		cutt.ly 縮短網址按鈕
// @name:zh-CN		cutt.ly 缩短网址按钮
// @description		set a URL-shorten button at the bottom left corner. It will create a new window for the shortened URL of cutt.ly.
// @description:zh-TW	在頁面左下角設置一個縮短網址的按鈕,這會開個新視窗來檢視 cutt.ly 的縮址結果
// @description:zh-CN	在页面左下角设置一个缩短网址的按钮,这会开个新视窗来检视 cutt.ly 的缩址结果
// @namespace		https://greasyfork.org/zh-TW/users/393133-evan-tseng
// @version		0.1
// @author		Evan Tseng
// @include		*://*
// @exclude		*://cutt.ly/*
// @grant		none
// ==/UserScript==

(async function() {
	'use strict';

	const CuttURL = 'https://cutt.ly/?shortenit='+encodeURIComponent(location.href);

	let strWindowFeatures = 'width=500, height=874, menubar=no, location=yes, resizable=no, status=no';
	var shortenWrap = null,
		shortenButton = null;
	const css = '.__shorten_wrap__ {position: fixed; bottom:20mm; left:-33px; z-index:2147483647}'+
		  '.__shorten_url__ {font: 400 11pt sans-serif; color:#555; background:#eee; padding: 1mm 2mm 2mm; margin:0; line-height:1.1; border:1px solid #555; border-radius:5px; cursor:pointer; transform:rotate(90deg)}'+
		  '.__shorten_url__:hover {color:#448; background:#fff; box-shadow:0 0 2mm rgba(0,0,0,.5)}'+
		  '.__shorten_url__:active {color:#333; background:#eee; box-shadow:inset 0 0 5px rgba(0,0,0,.5)}',
		  cssStyle = document.createElement('style');
	if(cssStyle.styleSheet)	cssStyle.styleSheet.cssText = css;
	else	cssStyle.appendChild(document.createTextNode(css));
	document.querySelector('head').appendChild(cssStyle);

	shortenWrap = document.createElement('div');
	shortenWrap.setAttribute("class", "__shorten_wrap__");
	document.body.appendChild(shortenWrap);

	shortenButton = document.createElement('button');
	shortenButton.setAttribute("class", "__shorten_url__");
	shortenButton.innerText="Cutt URL";
	shortenWrap.appendChild(shortenButton);
	shortenButton.addEventListener("click", function(){
		window.open(CuttURL, "Cuttly URL", strWindowFeatures);
	});

})();