Jump to AliWangWang in 64bit Browser

Fix AliWangWang link can't jump in 64bit browser

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Jump to AliWangWang in 64bit Browser
// @name:zh-CN	64位浏览器跳转到阿里旺旺
// @namespace   http://www.mapaler.com/
// @description Fix AliWangWang link can't jump in 64bit browser
// @description:zh-CN	解决阿里旺旺无法连接在64位浏览器跳转的问题
// @include     *://*.taobao.com/*
// @include     *://*.tmall.com/*
// @include     *://*.jiyoujia.com/*
// @include     *://*.juhuasuan.com/*
// @include     *://*.1688.com/*
// @version     1.0.1
// @copyright	2017+, Mapaler <[email protected]>
// @grant       GM_xmlhttpRequest
// ==/UserScript==

var findAliWangWangLink = function(e) {
    var t = null,otar = e.target;
    if (otar.tagName == "A")
    {
        t = otar;
    }else if(t = e.target.querySelector("a"))
    { //寻找是否有链接
        //什么都不做
    }else if(otar.classList.contains("tb-toolbar-item-icon"))
    { //侧边栏上的
        var nlnk = otar.parentElement.previousElementSibling; //父级的上一个兄弟
        if (nlnk.classList.contains("ww-light"))
        {
            var t = nlnk.querySelector("a");
        }
    }else if(otar.parentElement.tagName == "A")
    { //图片链接类
        var t = otar.parentElement;
    }

    if (t && t.href.indexOf("amos.alicdn.com") > 0) //判断链接是否是链接到阿里旺旺
    {
        //console.log("找到对象", t);
        convHttpToAliim(t,otar);
    }
};
//给文档添加寻找事件
document.addEventListener("click", findAliWangWangLink);
//把链接转换为阿里旺旺的链接
function convHttpToAliim(link,otar) {
    function idToAliim(a1) {
        return "aliim:sendmsg?touid=" + a1.site + a1.touid + "&site=" + a1.site + "&status=1";
    }
    GM_xmlhttpRequest({
        method: "get",
        url: link.href,
        onload: function(response) {
            var _link=link;
            var html = response.responseText;
            var siteReg = /window\.site\s*=\s*('|")(.+?)\1/ig;
            var touidReg = /window\.touid\s*=\s*('|")(.+?)\1/ig;
            var siteRegResult = siteReg.exec(html);
            var touidRegResult = touidReg.exec(html);
            var a = { site: siteRegResult[2], touid: touidRegResult[2] };
            _link.href = idToAliim(a);
            _link.onclick = function() {return false;}
            otar.onclick = function() {location = _link.href;}
            location = _link.href;
        },
        onerror: function(response) {
            console.error(response);
        }
    })

}