練習ページ/1007

Cached: 2025-06-21 20:12:31 Last-modified: 2025-06-10 (火) 22:02:51

リンクをクリップボードにコピーという部分をクリックすると
[ページ名+タイムスタンプ]をリンクテキストとし、該当コメントログへのリンクをクリップボードにコピーする機能

例:練習ページ/1007 2025-06-04(水) 22:07:42

タイトルなし_1.png

manifest.json

{
  "manifest_version": 3,
  "name": "wikiwiki_difflog_add_copy_button",
  "version": "1.0.0.0",
  "host_permissions": ["/./*"],
  "content_scripts": [
    {
      "matches": ["/./*"],
      "js": ["jquery-3.7.1.min.js", "content.js"]
    }
  ]
}

content.js

function linkCopy(a_tag) {
    const elem = a_tag.closest('.diff-log-info').find('a');
    const link = ('[[' + elem.eq(0).text() + ' ' + elem.eq(5).text() + '>' + location.origin + elem.eq(5).attr('href') + ']]');
    navigator.clipboard.writeText(link);
}
if (location.href.indexOf('/./::cmd/diff_log') === 0) {
    const icon = $('.svg-inline--fa.fa-arrow-up-right-from-square').first().prop('outerHTML');
    $('.diff-log-info').each(function () {
        const $link = $('<a href="javascript:void(0)" class="diff-log-info-operation-button" style="color:#215dc6"> リンクをクリップボードにコピー ' + icon + '</a>');
        $link.on('click', function () {
            linkCopy($(this));
        });
        $(this).find('.diff-log-info-header ul').append($('<li>').append($link));
    });
}

jquery-3.7.1.min.js

[[https://jquery.com/download/>https://jquery.com/download/]] [Download jQuery 3.7.1] より利用