cutt.ly URL shorten button

set a URL-shorten button at the bottom left corner

2020-04-20 기준 버전입니다. 최신 버전을 확인하세요.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

})();