Greasy Fork

Greasy Fork is available in English.

二维码快速生成 FastQrcode

fast qrcode 选中文字快速生成二维码

当前为 2021-07-27 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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
// ==/UserScript==

(function() {
	'use strict';
	var code={
		addElement:function(){
			var tooltip = jQuery('<div id="UndCover_Tooltip" style="display:none;width:auto; height:auto; padding:10px;background:orange no-repeat left top;"><a id="UndCover_Show">显示</a> <a id="UndCover_Current">网址</a> <a id="UndCover_Close">关闭</a></div>')
			var qrcode = jQuery('<div id="UndCover_Qrcode" style="display:none;z-index:999; display:block; position:fixed; left:300px; top:100px; margin:0; width:auto; height:auto;"></div>')
			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();
})();