LZTCommentLink

Add clickable link on comment date

目前為 2023-08-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name         LZTCommentLink
// @namespace    MeloniuM/LZT
// @version      1.2
// @description  Add clickable link on comment date
// @author       MeloniuM
// @license      MIT
// @match        http*://zelenka.guru/threads/*
// @match        http*://lolz.live/threads/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addLink(elem){
        const link = location.origin + location.pathname + '#' + $(elem).closest('.comment').attr('id');
        $(elem).wrap('<a href="' + link + '" class="item messageDateInBottom datePermalink" style="display: inline; margin-left: 0;" data-phr="Ссылка скопирована"></a>');
        $(elem).on('click', function(event){
            event.preventDefault();
            const $target = $(event.target).closest('a.messageDateInBottom');
            Clipboard.copy(encodeURI($target[0].href), $target[0]);
        });
    }

    //скроллинг до комментария и анимация при загрузке страницы
    if (location.hash != ''){
        var $scrollTo = $(location.hash);
        if ($scrollTo.length){
            $scrollTo.get(0).scrollIntoView();
            XenForo.animateBackgroundColor($scrollTo);
        }
    }


    $(document).ready(function(){
        $('.comment abbr.DateTime:not(a abbr.DateTime)').each(function(index){
            addLink(this);
        });
    });

    $('.thread_view').on('DOMNodeInserted', function(event) {//при добавлении комментария
        if (!$(event.target).is('.comment')) return;
        $(event.target).find('abbr.DateTime:not(a abbr.DateTime)').each(function(index){
            addLink(this);
        });
    });
})();

QingJ © 2025

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