// ==UserScript== // @name LZTHideCopyButton // @namespace http://tampermonkey.net/ // @version 2.0 // @description Расширение позволяет копировать соддержимое хайда по кнопке // @author MeloniuM // @license MIT // @match *://zelenka.guru/threads/* // @match *://lzt.market/threads/* // @match *://lolz.guru/threads/* // @match *://lolz.live/threads/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; function addButton(elem) { if (!(elem instanceof HTMLElement)) return; let i = document.createElement('i') i.setAttribute('class', 'fa--xf far fa-paste HideCopy') i.setAttribute('data-phr', 'Содержимое было скопировано в буфер обмена') i.setAttribute('aria-hidden', 'true') i.style.marginLeft = '5px' elem.appendChild(i) } $( document ).ready(function() {//при загрузке $('.bbCodeBlock.bbCodeQuote.bbCodeHide').each(function( index ) { addButton($( this ).find('.attribution.type')[0]) }); }); $('.messageList').on('DOMNodeInserted', function(event) {//при добавлении сообщения $(event.target).find('.bbCodeBlock.bbCodeQuote.bbCodeHide').each(function( index ) { addButton($( this ).find('.attribution.type')[0]) }); }); $('.bbCodeBlock.bbCodeQuote.bbCodeHide .attribution.type .HideCopy').on('click', function(event) {//при клике let quote = $(event.target).closest('.bbCodeBlock.bbCodeQuote.bbCodeHide').find('.quote')[0] var range = document.createRange(); range.selectNode(quote); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); document.execCommand('copy'); event.target.classList.add("animated"); animateCSS(event.target, ["heartBeat", "mainc"]); XenForo.alert(event.target.getAttribute("data-phr"), "", 5e3); }) })();