EugeneLiu

自动推荐智能的标签

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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;
        }
    });
})();