// ==UserScript== // @name 아프리카TV - 댓글 링크복사 스크립트 // @namespace http://afreecatv.com/ // @version 0.0.3 // @description 아프리카TV 게시글의 댓글 링크를 바로 복사할 수 있도록 도와주는 익스텐션입니다. // @author You // @match https://bj.afreecatv.com/*/post/* // @icon https://www.google.com/s2/favicons?sz=64&domain=afreecatv.com // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/499110/%EC%95%84%ED%94%84%EB%A6%AC%EC%B9%B4TV%20-%20%EB%8C%93%EA%B8%80%20%EB%A7%81%ED%81%AC%EB%B3%B5%EC%82%AC%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8.user.js // @updateURL https://update.greasyfork.icu/scripts/499110/%EC%95%84%ED%94%84%EB%A6%AC%EC%B9%B4TV%20-%20%EB%8C%93%EA%B8%80%20%EB%A7%81%ED%81%AC%EB%B3%B5%EC%82%AC%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8.meta.js // ==/UserScript== /* * arrive.js * v2.4.1 * https://github.com/uzairfarooq/arrive * MIT licensed * * Copyright (c) 2014-2017 Uzair Farooq */ var Arrive=function(e,t,n){"use strict";function r(e,t,n){l.addMethod(t,n,e.unbindEvent),l.addMethod(t,n,e.unbindEventWithSelectorOrCallback),l.addMethod(t,n,e.unbindEventWithSelectorAndCallback)}function i(e){e.arrive=f.bindEvent,r(f,e,"unbindArrive"),e.leave=d.bindEvent,r(d,e,"unbindLeave")}if(e.MutationObserver&&"undefined"!=typeof HTMLElement){var o=0,l=function(){var t=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(e,n){return e instanceof HTMLElement&&t.call(e,n)},addMethod:function(e,t,r){var i=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof i?i.apply(this,arguments):n}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var n,r=0;n=e[r];r++)n&&n.callback&&n.callback.call(n.elem,n.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,n,r){for(var i,o=0;i=e[o];o++)n(i,t,r)&&r.push({callback:t.callback,elem:i}),i.childNodes.length>0&&l.checkChildNodesRecursively(i.childNodes,t,n,r)},mergeArrays:function(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r},toElementsArray:function(t){return n===t||"number"==typeof t.length&&t!==e||(t=[t]),t}}}(),c=function(){var e=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return e.prototype.addEvent=function(e,t,n,r){var i={target:e,selector:t,options:n,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},e.prototype.removeEvent=function(e){for(var t,n=this._eventsBucket.length-1;t=this._eventsBucket[n];n--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(n,1);r&&r.length&&(r[0].callback=null)}},e.prototype.beforeAdding=function(e){this._beforeAdding=e},e.prototype.beforeRemoving=function(e){this._beforeRemoving=e},e}(),a=function(t,r){var i=new c,o=this,a={fireOnAttributesModification:!1};return i.beforeAdding(function(n){var i,l=n.target;(l===e.document||l===e)&&(l=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(e){r.call(this,e,n)});var c=t(n.options);i.observe(l,c),n.observer=i,n.me=o}),i.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,n){t=l.mergeArrays(a,t);for(var r=l.toElementsArray(this),o=0;o0?l.checkChildNodesRecursively(n,t,r,o):"attributes"===e.type&&r(i,t,o)&&o.push({callback:t.callback,elem:i}),l.callCallbacks(o,t)})}function r(e,t){return l.matchesSelector(e,t.selector)&&(e._id===n&&(e._id=o++),-1==t.firedElems.indexOf(e._id))?(t.firedElems.push(e._id),!0):!1}var i={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};f=new a(e,t);var c=f.bindEvent;return f.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t);var o=l.toElementsArray(this);if(t.existing){for(var a=[],s=0;s0&&l.checkChildNodesRecursively(n,t,r,i),l.callCallbacks(i,t)})}function r(e,t){return l.matchesSelector(e,t.selector)}var i={};d=new a(e,t);var o=d.bindEvent;return d.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t),o.call(this,e,t,r)},d},f=new s,d=new u;t&&i(t.fn),i(HTMLElement.prototype),i(NodeList.prototype),i(HTMLCollection.prototype),i(HTMLDocument.prototype),i(Window.prototype);var h={};return r(f,h,"unbindAllArrive"),r(d,h,"unbindAllLeave"),h}}(window,"undefined"==typeof jQuery?null:jQuery,void 0); (function () { "use strict"; function findComment(obj) { if (obj) { if (typeof obj === "object" && obj.hasOwnProperty("comment")) { return obj.comment; } for (let key in obj) { if (key === "children" || key === "props" || !isNaN(key)) { const result = findComment(obj[key]); if (result) { return result; } } } } } $(document).arrive("div > section > ul.cmmt-list > li", { existing: true }, function (node) { const link_btn = document.createElement("button"); link_btn.textContent = "링크복사"; link_btn.setAttribute("type", "button"); link_btn.classList.add("btn-basic"); link_btn.addEventListener("click", (event) => { const target = event.currentTarget.parentNode; let comment = null; for (let attr in target) { if (attr.startsWith("__reactEventHandlers$")) { let data = node[attr]; if (data) { comment = findComment(data); } break; } } const url = location.origin + location.pathname + (comment ? "#comment_noti" + comment.p_comment_no : ""); navigator.clipboard.writeText(url).then(() => alert(url + "\n클립보드에 링크가 복사되었습니다.")); }); // attach button node.querySelector(".cmmt-btn")?.append(link_btn); }); })();