// ==UserScript== // @name 二维码快速生成 FastQrcode // @namespace http://tampermonkey.net/ // @version 0.3 // @description fast qrcode 选中文字快速生成二维码 // @author UndCover // @include *:* // @require https://cdn.staticfile.org/jquery/1.10.0/jquery.min.js // @require https://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js // @downloadURL none // ==/UserScript== (function() { 'use strict'; var code={ addElement:function(){ var tooltip = jQuery('') var qrcode = jQuery('') jQuery('body').append(tooltip) jQuery('body').append(qrcode) // $(".UndCoverIcon").css({ // "width": "30px", // "height": "30px", // "fill": "#80808080", // "overflow": "hidden" // }); }, eventHandle:function(){ var selection = ""; $("body").mouseup(function (e) { $("#UndCover_Tooltip").hide(); var x = 10; var y = 10; var r = ""; if (document.selection) { r = document.selection.createRange().text; } else if (window.getSelection()) { r = window.getSelection(); } if (r!= "") { selection = r.toString(); $("#UndCover_Tooltip").css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px", "position": "absolute" }).show("fast"); $("#UndCover_Tooltip").show(); } }) $("#UndCover_Show").click(function(){ $('#UndCover_Qrcode').empty(); $('#UndCover_Qrcode').qrcode(selection); $('#UndCover_Qrcode').show(); }) $("#UndCover_Current").click(function(){ $('#UndCover_Qrcode').empty(); $('#UndCover_Qrcode').qrcode(window.location.href); $('#UndCover_Qrcode').show(); }) $("#UndCover_Close").click(function(){ $("#UndCover_Tooltip").hide(); }) $("#UndCover_Qrcode").click(function(){ $("#UndCover_Qrcode").hide(); }) } } code.addElement(); code.eventHandle(); })();