EugeneLiu

自动推荐智能的标签

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            EugeneLiu
// @icon            https://d32kak7w9u5ewj.cloudfront.net/media/image/2017/10/382f873c678a418c9f8f3ce8a2485378.jpg
// @version         2.1.2
// @include         *
// @copyright       2018, AC
// @description     自动推荐智能的标签
// @author          刘一辰,黄嘉晟
// @note            2018.4.7-00:17-V1.1 第一版本
// @grant           none
// @require         http://code.jquery.com/jquery-1.11.0.min.js
// @namespace http://www.eugeneliu.xyz
// ==/UserScript==
(function () {
    document.body.innerHTML += "<input type='text' style='position: fixed;margin: 0 40%;top: 50px;text-align: center;color: red' id='EugeneInput'></input>";
    $("a").hover(function () {
            document.getElementById('EugeneInput').value = '';
            console.log("开始请求数据");
            $.ajax(
                {
                    //url: "http://localhost/requestTag",
                    url: "https://www.eugeneliu.top/server/requestTag",
                    type: "POST",
                    data: {"requestUrl": $(this).attr('href')},
                    success: function (result) {
                        console.log('result->' + result);
                        result = JSON.parse(result);
                        var recommendedTag = result.tag;
                        console.log("originalTag->" + recommendedTag);
                        recommendedTag = decodeURIComponent(recommendedTag);
                        console.log('decodedRecommendedTag->' + recommendedTag);
                        document.getElementById('EugeneInput').value = recommendedTag;
                    },
                    error: function (result) {
                        console.log(result);
                    }
                });
        }, function () {
            console.log('mouse out');
        }
    );
    $("a").click(function () {
        var linkHref = $(this).attr('href');
        if (linkHref.indexOf("javascript") > 0) {

        } else {
            if (linkHref.indexOf("https") === 0 || linkHref.indexOf("http") === 0) {

            }else if(linkHref.indexOf("/")==0){
                linkHref = "http:"+linkHref;
            }
            else {
                var url = window.location.href;
                var baseUrl = url.substring(url.indexOf(0, url.lastIndexOf("/")));
                var completeUrl = baseUrl + linkHref;
            }
            window.location.href = linkHref;
        }
    });
})();