tinyurl.com - URL shorten button

Add a URL shorten button to the bottom left corner. It will create a new window for the shortened URL of tinyurl

2021-10-13 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name				tinyurl.com - URL shorten button
// @name:zh-TW			tinyurl.com 縮短網址按鈕
// @name:zh-CN			tinyurl.com 缩短网址按钮
// @description			Add a URL shorten button to the bottom left corner. It will create a new window for the shortened URL of tinyurl
// @description:zh-TW	在頁面左下角設置一個縮短網址的按鈕,這會開個新視窗來檢視 tinyurl 的縮址結果
// @description:zh-CN	在页面左下角设置一个缩短网址的按钮,这会开个新视窗来查看 tinyurl 的缩址结果
// @namespace			https://greasyfork.org/zh-TW/users/393133-evan-tseng
// @version				0.23
// @author				Evan Tseng
// @run-at				document-end
// @include				*://*
// @exclude				*://tinyurl.com/*
// @grant				none
// ==/UserScript==

(function() {
	'use strict';
	if(self == top) {
		var addTinyButton = (function() {
			if(document.readyState == "loading")	return setTimeout(addTinyButton, 500);

			setTimeout(function(){
				const windowWidth = 760,
					  windowHeight = (navigator.appVersion.indexOf("Mac")!=-1)? 600 : 640;
				let strWindowFeatures = 'width=' + windowWidth + ',height=' + windowHeight + ',left=' + ((screen.width - windowWidth) / 2) + ',top=' + ((screen.height - windowHeight) / 3) + ',menubar=no,toolbar=no,location=no,status=no',
					cssStyle = document.createElement('style'),
					css = `
.__shorten_wrap__ { position:fixed; bottom:22mm; left:-.7em; display:block; width:0; height:0; z-index:2147483646; opacity:.5; transform:rotate(90deg); transition:.8s .1s }
.__shorten_wrap__:hover { left:0; opacity:1; transition:.2s }
.__shorten_btn__ { position:absolute!important; bottom:-10px!important; right:0!important; font:400 11pt sans-serif!important; width:auto!important; max-width:none!important; color:#334!important; text-shadow:1px -1px rgba(255,255,255,.6); background:linear-gradient(5deg, rgba(170,170,175,.85) 0, rgba(210,210,215,.8) 50%, rgba(170,170,175,.85) 100%)!important; padding:.3em .6em 1em!important; margin:0!important; line-height:1!important; border:1px solid #555!important; border-radius:6px 6px 0 0!important; white-space:nowrap; cursor:pointer!important; transition:.15s!important }
.__shorten_btn__:focus { outline:none }
.__shorten_btn__:hover { background:linear-gradient(5deg, rgba(190,190,190,.95) 0, rgba(230,230,230,.95) 50%, rgba(190,190,190,.95) 100%)!important; border:1px solid rgba(0,0,0,.4)!important; box-shadow:2pt 0 5pt rgba(0,0,0,.5)!important }
.__shorten_btn__:active { color:#cdf!important; text-shadow:-1px 1px #666!important; background:rgba(125,125,133,.8)!important; border-color:rgba(255,255,255,.6)!important; box-shadow:inset 1px 0 4pt rgba(0,0,0,.7)!important; transition:0s!important }
@media not screen { .__shorten_wrap__ { display:none } }`;
				if(cssStyle.styleSheet)	cssStyle.styleSheet.cssText = css;
				else	cssStyle.appendChild(document.createTextNode(css));
				document.querySelector('head').appendChild(cssStyle);

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

				let shortenButton = document.createElement('button');
				shortenButton.setAttribute("class", "__shorten_btn__");
				shortenButton.innerText = "TinyURL";
				shortenWrap.appendChild(shortenButton);

				shortenButton.addEventListener("click", function(){
					window.open('https://tinyurl.com/create.php?app=scpt&url=' + encodeURIComponent(location.href), "", strWindowFeatures);
				});
			}, 500);
		})();
	}
})();