cutt.ly 縮短網址按鈕

在頁面左下角設置一個縮短網址的按鈕,這會開個新視窗來檢視 cutt.ly 的縮址結果

目前為 2020-04-20 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name cutt.ly URL shorten button
  3. // @name:zh-TW cutt.ly 縮短網址按鈕
  4. // @name:zh-CN cutt.ly 缩短网址按钮
  5. // @description set a URL-shorten button at the bottom left corner. It will create a new window for the shortened URL of cutt.ly.
  6. // @description:zh-TW 在頁面左下角設置一個縮短網址的按鈕,這會開個新視窗來檢視 cutt.ly 的縮址結果
  7. // @description:zh-CN 在页面左下角设置一个缩短网址的按钮,这会开个新视窗来检视 cutt.ly 的缩址结果
  8. // @namespace https://greasyfork.org/zh-TW/users/393133-evan-tseng
  9. // @version 0.1
  10. // @author Evan Tseng
  11. // @include *://*
  12. // @exclude *://cutt.ly/*
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (async function() {
  17. 'use strict';
  18.  
  19. const CuttURL = 'https://cutt.ly/?shortenit='+encodeURIComponent(location.href);
  20.  
  21. let strWindowFeatures = 'width=500, height=874, menubar=no, location=yes, resizable=no, status=no';
  22. var shortenWrap = null,
  23. shortenButton = null;
  24. const css = '.__shorten_wrap__ {position: fixed; bottom:20mm; left:-33px; z-index:2147483647}'+
  25. '.__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)}'+
  26. '.__shorten_url__:hover {color:#448; background:#fff; box-shadow:0 0 2mm rgba(0,0,0,.5)}'+
  27. '.__shorten_url__:active {color:#333; background:#eee; box-shadow:inset 0 0 5px rgba(0,0,0,.5)}',
  28. cssStyle = document.createElement('style');
  29. if(cssStyle.styleSheet) cssStyle.styleSheet.cssText = css;
  30. else cssStyle.appendChild(document.createTextNode(css));
  31. document.querySelector('head').appendChild(cssStyle);
  32.  
  33. shortenWrap = document.createElement('div');
  34. shortenWrap.setAttribute("class", "__shorten_wrap__");
  35. document.body.appendChild(shortenWrap);
  36.  
  37. shortenButton = document.createElement('button');
  38. shortenButton.setAttribute("class", "__shorten_url__");
  39. shortenButton.innerText="Cutt URL";
  40. shortenWrap.appendChild(shortenButton);
  41. shortenButton.addEventListener("click", function(){
  42. window.open(CuttURL, "Cuttly URL", strWindowFeatures);
  43. });
  44.  
  45. })();