MyAnimeList(MAL) - Com-to-Com Links

Add Com-to-Com link between user and comment user for every comment.

目前为 2015-12-04 提交的版本。查看 最新版本

// ==UserScript==
// @name            MyAnimeList(MAL) - Com-to-Com Links
// @version         1.1.1
// @description	    Add Com-to-Com link between user and comment user for every comment.
// @author          Cpt_mathix & N_Ox
// @include         http://myanimelist.net/profile*
// @include         http://myanimelist.net/comments*
// @exclude         http://myanimelist.net/profile/*/reviews
// @exclude         http://myanimelist.net/profile/*/recommendations
// @exclude         http://myanimelist.net/profile/*/clubs
// @exclude         http://myanimelist.net/profile/*/friends
// @grant           none
// @namespace https://gf.qytechs.cn/users/16080
// ==/UserScript==

if (document.location.href.indexOf('profile') > -1) {
    var element = document.getElementById('lastcomment').getElementsByTagName('a');
    for(var i = 0; i < element.length; i++) {
        if (element[i].innerHTML.indexOf("All Comments") > -1) {
            comtocom(element[i].href);
            break;
        }
    }
} else
	comtocom(document.location.href);

function comtocom(url) {
    if (typeof jQuery == 'undefined') $ = unsafeWindow.$;

    var i = url.indexOf('id=');
    if (i == -1) return;
    url = 'http://myanimelist.net/comtocom.php?id1=' + url.substr(i + 3) + '&id2=';

    if (document.location.href.indexOf('profile') == -1) {
        $('div[id^=comBox] > table > tbody > tr').each(function () {
            var avatar = $('.picSurround img', this);
            if (!avatar.length) return;

            var com = $('div[id^=com]:not([id^=comtext])', this);
            if (!com.length) return;
            if (com.children().length == 3) return;

            var id = avatar.attr('src');
            var i = id.indexOf('thumbs/');
            if (i == -1) return;
            id = id.substr(i + 7, id.indexOf('_') - i - 7);

            com.append(
                $('<div style="margin-top:10px" align="right"/>').append(
                    $('<a title="Comment-to-Comment">Conversation</a>').attr('href', url + id)));
        });
    } else {
        $('div[id^=comBox]').each(function () {
            if (this.getElementsByClassName('postActions ar mt4').length != 0)
                return;
            
            var avatar = $('img', this);
            if (!avatar.length) return;
            
            var id = avatar.attr('src');
            var i = id.indexOf('userimages/');
            if (i == -1) return;          
            id = id.substr(i + 11, id.indexOf('.jpg') - i - 11);
            
            var div = document.createElement('div');
            div.className = 'postActions ar mt4 mr12';
            var link = document.createElement('a');
            link.href = url + id;
            link.innerHTML = "Conversation";
            
            div.appendChild(link);
            this.appendChild(div);
        });
    }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址