cutt.ly URL shorten button

set a URL-shorten button at the bottom left corner

Από την 20/04/2020. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);
	});

})();