cutt.ly URL shorten button

set a URL-shorten button at the bottom left corner

Stan na 20-04-2020. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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
// @description:zh-TW	在頁面左下角設置一個縮短網址的按鈕
// @description:zh-CN	在页面左下角设置一个缩短网址的按钮
// @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);
	});

})();