Wowhead Model ID

Extract model ID from wowhead pages

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Wowhead Model ID
// @namespace    blep
// @version      1.0
// @description  Extract model ID from wowhead pages
// @match        https://www.wowhead.com/*
// @author       Blehssing
// @grant        none
// @license      Blehssing
// ==/UserScript==

(function () {
    'use strict';

    const src = document.documentElement.innerHTML;

    const patterns = [
        /displayId\s*=\s*(\d+)/,
        /"npcmodel"\s*:\s*(\d+)/,
        /displayId"\s*:\s*(\d+)/,
    ];

    let displayId = null;
    for (const re of patterns) {
        const m = src.match(re);
        if (m) { displayId = m[1]; break; }
    }

    const panel = document.createElement('div');
    panel.id = 'igm-displayid-panel';
    Object.assign(panel.style, {
        position:     'fixed',
        top:          '80px',
        right:        '20px',
        zIndex:       '2147483647',
        background:   '#1a1a2e',
        border:       '1px solid #4a4a8a',
        borderRadius: '8px',
        padding:      '10px 14px 10px 14px',
        fontFamily:   'monospace',
        fontSize:     '13px',
        color:        '#e0e0ff',
        boxShadow:    '0 4px 18px rgba(0,0,0,0.7)',
        userSelect:   'none',
        minWidth:     '180px',
        cursor:       'move',
    });

    const label = document.createElement('div');
    label.textContent = 'Display ID';
    Object.assign(label.style, {
        fontSize:     '10px',
        color:        '#8888bb',
        marginBottom: '4px',
        letterSpacing:'0.08em',
        textTransform:'uppercase',
    });

    const idLine = document.createElement('div');
    Object.assign(idLine.style, {
        display:    'flex',
        alignItems: 'center',
        gap:        '8px',
    });

    const idText = document.createElement('span');
    idText.textContent = displayId ?? '—';
    Object.assign(idText.style, {
        fontSize:   '20px',
        fontWeight: 'bold',
        color:      displayId ? '#7ec8e3' : '#666',
        flex:       '1',
    });

    const copyBtn = document.createElement('button');
    copyBtn.textContent = '⎘';
    copyBtn.title = 'Copier';
    Object.assign(copyBtn.style, {
        background:   '#2a2a5e',
        border:       '1px solid #5555aa',
        borderRadius: '4px',
        color:        '#aaaaff',
        cursor:       'pointer',
        fontSize:     '15px',
        lineHeight:   '1',
        padding:      '2px 6px',
        transition:   'background 0.15s',
    });

    if (!displayId) copyBtn.disabled = true;

    copyBtn.addEventListener('click', () => {
        if (!displayId) return;
        navigator.clipboard.writeText(displayId).then(() => {
            copyBtn.textContent = '✓';
            copyBtn.style.color = '#66ffaa';
            setTimeout(() => {
                copyBtn.textContent = '⎘';
                copyBtn.style.color = '#aaaaff';
            }, 1200);
        });
    });

    idLine.appendChild(idText);
    idLine.appendChild(copyBtn);
    panel.appendChild(label);
    panel.appendChild(idLine);

    if (!displayId) {
        const warn = document.createElement('div');
        warn.textContent = 'Introuvable sur cette page';
        Object.assign(warn.style, { fontSize: '10px', color: '#ff8888', marginTop: '4px' });
        panel.appendChild(warn);
    }

    document.body.appendChild(panel);

    let ox = 0, oy = 0, dragging = false;

    panel.addEventListener('mousedown', (e) => {
        if (e.target === copyBtn) return;
        dragging = true;
        ox = e.clientX - panel.getBoundingClientRect().left;
        oy = e.clientY - panel.getBoundingClientRect().top;
        e.preventDefault();
    });

    document.addEventListener('mousemove', (e) => {
        if (!dragging) return;
        panel.style.left   = (e.clientX - ox) + 'px';
        panel.style.top    = (e.clientY - oy) + 'px';
        panel.style.right  = 'auto';
    });

    document.addEventListener('mouseup', () => { dragging = false; });

})();