GoTo115

选择115礼包码后直接打开接收界面

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GoTo115
// @namespace    http://bbs.fuli.ba/?fromuser=benbenben
// @version      0.2
// @description  选择115礼包码后直接打开接收界面
// @author       benbenben
// @match        http://*/*
// @match        https://*/*
// @grant        none
// ==/UserScript==

var $imgLink = "http://ww3.sinaimg.cn/mw690/61ceb008jw1ereg3uqk73j206e06eq2s.jpg";
var $goTo115LB = function(eleGotoUI, eleContainer) {
    var re = /5lb[a-z0-9]{5,9}/ig;
	var eleTitle = document.getElementsByTagName("title")[0];
	eleContainer = eleContainer || document;
	var funGetSelectTxt = function() {
		var txt = "";
		if(document.selection) {
			txt = document.selection.createRange().text;	// IE
		} else {
			txt = document.getSelection();
		}
        return txt.toString();
	};
	eleContainer.onmouseup = function(e) {
		e = e || window.event;
		var txt = funGetSelectTxt(), sh = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
		var left = (e.clientX - 40 < 0) ? e.clientX + 20 : e.clientX - 40, top = (e.clientY - 40 < 0) ? e.clientY + sh + 20 : e.clientY + sh - 40;
		if (re.test(txt)) {
			eleGotoUI.style.display = "inline";
			eleGotoUI.style.left = left + "px";
			eleGotoUI.style.top = top + "px";
		} else {
			eleGotoUI.style.display = "none";
		}
	};
	eleGotoUI.onclick = function() {
		var txt = funGetSelectTxt();
		if (txt) {
            var lbs = txt.match(re);
            if (lbs) {
                for (var x in lbs) {
                    window.open('http://115.com/lb/' + lbs[x]);
                }
            }
		}
	};
};

function addGlobalStyle(css) {
	var head, style;
	head = document.getElementsByTagName('head')[0];
	if (!head) { return; }
	style = document.createElement('style');
	style.type = 'text/css';
	style.innerHTML = css;
	head.appendChild(style);
}

function init() {
    addGlobalStyle('.img_115_logo{display:none; position:absolute; cursor:pointer; z-index: 100;}');
    var logo = document.createElement("p");
    logo.innerHTML = '<img width="26px" height="26px" id="img115Logo" class="img_115_logo" title="打开礼包文件" src="' + $imgLink + '" />';
    document.body.insertBefore(logo, document.body.firstChild);
}

init();
$goTo115LB(document.getElementById("img115Logo"));