cutt.ly 缩短网址按钮

在页面左下角设置一个缩短网址的按钮,这会开个新视窗来查看 cutt.ly 的缩址结果

当前为 2020-04-22 提交的版本,查看 最新版本

  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.13
  10. // @author Evan Tseng
  11. // @run-at document-end
  12. // @include *://*
  13. // @exclude http://cutt.ly/*
  14. // @exclude https://cutt.ly/*
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. var addCuttButton = (function() {
  22. if(document.readyState == "interactive") {
  23. const newWindow = window.open,
  24. CuttURL = 'https://cutt.ly/?shortenit=' + encodeURIComponent(location.href);
  25.  
  26. let strWindowFeatures = 'width=500,height=874,top='+((screen.height-874)/4)+',left='+((screen.width-500)/2)+',menubar=no,toolbar=no,location=no,status=no',
  27. shortenWrap = null,
  28. shortenButton = null,
  29. cssStyle = document.createElement('style'),
  30. css = `.__shorten_wrap__ {position: fixed; bottom:25mm; left:-25pt; z-index:2147483647}
  31. button.__shorten_url__ {font: 400 11pt Helvetica; color:#334; text-shadow:1px -1px rgba(255,255,255,.6); background:linear-gradient(3deg, rgba(170,170,175,.85) 0, rgba(210,210,215,.8) 50%, rgba(170,170,175,.85) 100%); padding: 0 .5em 1em; margin:0; line-height:2; border:1px solid rgba(0,0,0,.4); border-radius:5pt; cursor:pointer; transform:rotate(90deg); transition:.15s}
  32. button.__shorten_url__:hover {background:linear-gradient(5deg, rgba(190,190,190,.95) 0, rgba(230,230,230,.95) 50%, rgba(190,190,190,.95) 100%); border:1px solid rgba(0,0,0,.4); box-shadow:1px 0 4pt rgba(0,0,0,.5)}
  33. button.__shorten_url__:active {color:#cdf; text-shadow:-1px 1px #000; background:rgba(125,125,133,.8); border-color:rgba(255,255,255,.6); box-shadow:inset 1px 0 4pt rgba(0,0,0,.7); transition:0s}}`;
  34. if(cssStyle.styleSheet) cssStyle.styleSheet.cssText = css;
  35. else cssStyle.appendChild(document.createTextNode(css));
  36. document.querySelector('head').appendChild(cssStyle);
  37.  
  38. shortenWrap = document.createElement('div');
  39. shortenWrap.setAttribute("class", "__shorten_wrap__");
  40. document.body.appendChild(shortenWrap);
  41.  
  42. shortenButton = document.createElement('button');
  43. shortenButton.setAttribute("class", "__shorten_url__");
  44. shortenButton.innerText = "Cutt URL";
  45. shortenWrap.appendChild(shortenButton);
  46. shortenButton.addEventListener("click", function(){
  47. newWindow(CuttURL, "Cuttly URL", strWindowFeatures);
  48. });
  49. }
  50. else setTimeout(addCuttButton, 500);
  51. })();
  52.  
  53. })();