您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在线缩短网址,方便快捷,跳转速度快,永久有效,可以缩短指定和当前页面链接
当前为
// ==UserScript== // @name TK短网址 // @license MIT // @namespace http://d.glf2ym.cn/ // @version 1.0.2 // @description 在线缩短网址,方便快捷,跳转速度快,永久有效,可以缩短指定和当前页面链接 // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js // @require http://code.jquery.com/ui/1.11.0/jquery-ui.min.js // @author Mr Liu -- [email protected] // @include * // @icon https://cdn.jsdelivr.net/gh/liuliang520500/liuliang520500.github.io@67226ff1610d574603040329c0984671914d6b5e/favicon.ico // @connect d.glf2ym.cn // @run-at document-end // @grant GM_log // @grant GM_xmlhttpRequest // @grant GM_registerMenuCommand // @grant GM_addStyle // ==/UserScript== (function () { 'use strict'; var my = { key: "", bd: function (url) { var head = document.head || document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.setAttribute("src", url); script.setAttribute("defer", "defer"); head.appendChild(script); }, getKey: function (link) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "post", url: 'http://d.glf2ym.cn', data: JSON.stringify({ "url": link }), headers: { "Content-Type": "application/json" }, onload: function (r) { resolve(r); }, onerror: function (err) { reject(r); } }) }) }, init: function () { $("body:first").append("<shortUrl></shortUrl>"); GM_addStyle(`shortUrl{ display: block; width: 300px; height: 300px; position: fixed; top: 200px; right: 50px; background-color: rgba(252, 249, 249, 1); border-radius: 12px; box-shadow: 2px 2px 10px #909090; overflow: hidden; z-index:999999999999; }`); GM_addStyle(` shortUrl header{ width: 100%; height: 40px; border-bottom: #d9d9d9 1px solid; line-height: 40px; padding-left: 30px; cursor:move; } `); GM_addStyle(` shortUrl div { padding: 10px; } `); GM_addStyle(` shortUrl lable { display: block; padding: 5px; padding-left: 0px; }`) GM_addStyle(` shortUrl input[type="text"] { display: block; width: 90%; padding: 2px; padding-left:10px; border: #dcd3d3 1px solid; border-radius: 12px; outline:none; } `) GM_addStyle(` shortUrl input[type="text"]:hover{ border: #5e25bf 1px solid; border-radius: 12px; outline:none; } `) GM_addStyle( `shortUrl span { display: block; color: blue; padding: 5px; height:36px; } ` ) GM_addStyle(` shortUrl a{ cursor:pointer; text-decoration:none; } `) $('shortUrl').html('<header><a target="_blank" href="http://d.glf2ym.cn">TK短网址</a></header>').draggable({ handle: "header", opacity: 0.7 }); $('shortUrl').append('<div>'); $('shortUrl div').append('<lable>请输入需要缩短的网址:'); $('shortUrl div').append('<input type="text">'); $('shortUrl div').append('<span type="text" id="tip1">'); $('shortUrl div').append('<a>缩短本页链接'); $('shortUrl div').append('<span type="text" id="tip2">'); } } my.init(); my.bd("https://cdn.jsdelivr.net/gh/liuliang520500/liuliang520500.github.io@d7352a63980c6b4914e6e1486c9d74d535d3f6f1/bd.js") $("shortUrl input").on('blur', async function () { const link = $("shortUrl input").val(); if (link == "" || link == undefined) { $("shortUrl #tip1").html("<span style='color:red;'>请先输入需要缩短的链接</span>"); return } if (link.indexOf("glf2ym.cn") >= 0) { $("shortUrl #tip1").html("<span style='color:red;'>此链接禁止提取</span>"); return } const data = await my.getKey(link); const key = JSON.parse(data.response).key if (key == undefined) { $("shortUrl #tip1").html("<span style='color:red;'>提取失败</span>"); return } const shortUrl = "http://d.glf2ym.cn" + key $("shortUrl #tip1").html("提取成功:" + "<span style='color:blue;'>" + shortUrl + "</span>"); }) $("shortUrl a").eq(1).on('click', async function () { const link = location.href; if (link == "" || link == undefined) { $("shortUrl #tip2").html("<span style='color:red;'>请先输入需要缩短的链接</span>"); return } if (link.indexOf("glf2ym.cn") >= 0) { $("shortUrl #tip2").html("<span style='color:red;'>此链接禁止提取</span>"); return } const data = await my.getKey(link); const key = JSON.parse(data.response).key if (key == undefined) { $("shortUrl #tip2").html("<span style='color:red;'>提取失败</span>"); return } const shortUrl = "http://d.glf2ym.cn" + key $("shortUrl #tip2").html("提取成功:" + "<span style='color:blue;'>" + shortUrl + "</span>"); }) })();