Wowhead Model ID

Extract model ID from wowhead pages

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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; });

})();