IntelX.io Copy ID

Add a copy button to each search result to copy the data-id attribute

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         IntelX.io Copy ID
// @description  Add a copy button to each search result to copy the data-id attribute
// @author       You
// @match        https://intelx.io/*
// @grant        none
// @version      0.3.3
// @namespace    https://greasyfork.org/en/scripts/497675-intelx-copy-id
// @license      MIT
// @icon         data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+FFVn/hRVc/4UVXP+FFVz/hRVc/4UVXP+FFVb/hRUT/4UVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/hRXp/4UV7P+FFez/hRXs/4UV7P+FFe3/hRXh/4UVN/+FFRr/hRUf/4UVAv+FFQD/hRUA/4YWAP+FFRn/hRUq/4UVLf+FFS//hRUv/4UVL/+FFS//hRUv/4UVLP+FFQj/hRVz/4UV1P+FFTP/hRUA/4UVAP+FF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AA//8AAA==
// ==/UserScript==


(function() {
    'use strict';

    function appendCopyButton(element) {
        if (element.querySelector('.copy-btn')) return;

        let copyBtn = document.createElement('button');
        const dataId = element.getAttribute('data-id');
        if (dataId.length > 10) {
            copyBtn.textContent = dataId.substring(0, 5) + ' ... ' + dataId.substring(dataId.length - 5);
        } else {
            copyBtn.textContent = dataId;
        }
        copyBtn.className = 'copy-btn';
        copyBtn.style.marginRight = '10px';
        copyBtn.onclick = function() {
            navigator.clipboard.writeText(element.getAttribute('data-id'))
                .catch(err => console.error('Error copying data-id:', err));
        };

        element.insertAdjacentElement('beforebegin', copyBtn);
    }

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                let detailLink = node.querySelector('.prevResult .view_details');
                if (detailLink) {
                    appendCopyButton(detailLink);
                } else {
                    console.log("Detail link not found within search-result element.");
                }
            });
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });

    document.querySelectorAll('.prevResult .view_details').forEach(element => {
        appendCopyButton(element);
    });
})();