Greasy Fork is available in English.
Add clickable link on comment date
当前为
// ==UserScript==
// @name LZTCommentLink
// @namespace MeloniuM/LZT
// @version 1.1
// @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;" 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);
});
});
})();