DF Quick marks

Simple bookmark for market search

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         DF Quick marks
// @namespace    http://tampermonkey.net/
// @version      1.6.2
// @description  Simple bookmark for market search
// @author       SHUN
// @license      SHUN
// @match        *://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=35
// @match        *://*.deadfrontier.com/onlinezombiemmo/index.php?page=35
// @grant        none
// @icon         https://i.imgur.com/wDmstST.png
// @run-at       document-end

// ==/UserScript==

(function() {
    'use strict';

    // Wait for page load
    setTimeout(init, 2000);

    function init() {
        if (!window.location.href.includes('page=35')) return;

        console.log('Simple Bookmarks started');

        // Prevent duplicate creation
        if (document.getElementById('simple-bookmarks')) return;

        // Create main frame
        const frame = document.createElement('div');
        frame.id = 'simple-bookmarks';
        frame.style.cssText = `
            position: fixed;
            top: 580px;
            right: 250px;
            width: 180px;
            background: rgba(40, 40, 40, 0.9);
            border: 1px solid #666;
            border-radius: 5px;
            z-index: 9999;
            padding: 10px;
            font-family: Arial, sans-serif;
        `;

        // Title
        const title = document.createElement('div');
        title.textContent = 'Bookmarks';
        title.style.cssText = `
            color: white;
            font-weight: bold;
            font-size: 14px;
            margin-bottom: 10px;
            text-align: center;
        `;
        frame.appendChild(title);

        // Input field
        const input = document.createElement('input');
        input.type = 'text';
        input.placeholder = 'Item Name';
        input.style.cssText = `
            width: 100%;
            padding: 6px;
            margin-bottom: 8px;
            border: 1px solid #555;
            border-radius: 3px;
            background: #333;
            color: white;
            font-size: 12px;
            box-sizing: border-box;
        `;
        frame.appendChild(input);

        // Button container
        const buttonContainer = document.createElement('div');
        buttonContainer.style.cssText = `
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        `;

        // Save button
        const saveBtn = document.createElement('button');
        saveBtn.textContent = 'Save';
        saveBtn.style.cssText = `
            padding: 6px 12px;
            background: #28a745;
            color: white;
            border: none;
            border-radius: 3px;
            font-size: 12px;
            cursor: pointer;
            flex: 1;
            margin-right: 5px;
        `;

        // Move button
        const moveBtn = document.createElement('button');
        moveBtn.textContent = 'Move';
        moveBtn.style.cssText = `
            padding: 6px 12px;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 3px;
            font-size: 12px;
            cursor: pointer;
            flex: 1;
            margin-left: 5px;
        `;

        buttonContainer.appendChild(saveBtn);
        buttonContainer.appendChild(moveBtn);
        frame.appendChild(buttonContainer);

        // Item list
        const list = document.createElement('div');
        list.id = 'bookmarks-list';
        list.style.cssText = `
            max-height: 200px;
            overflow-y: auto;
            font-size: 12px;
        `;
        frame.appendChild(list);

        // Add to page
        document.body.appendChild(frame);

        // Load saved items
        const savedItems = loadItems();
        renderList();

        // Save function
        saveBtn.onclick = () => {
            const item = input.value.trim();
            if (item && !savedItems.includes(item)) {
                savedItems.push(item);
                saveItems(savedItems);
                renderList();
                input.value = '';
            }
        };

        // Move function
        let isDragging = false;
        let dragOffsetX = 0;
        let dragOffsetY = 0;

        moveBtn.onclick = () => {
            isDragging = !isDragging;
            moveBtn.textContent = isDragging ? 'Stop' : 'Move';
            moveBtn.style.background = isDragging ? '#dc3545' : '#007bff';
        };

        frame.addEventListener('mousedown', (e) => {
            if (!isDragging) return;

            e.preventDefault();
            dragOffsetX = e.clientX - frame.getBoundingClientRect().left;
            dragOffsetY = e.clientY - frame.getBoundingClientRect().top;

            function mouseMoveHandler(e) {
                frame.style.left = (e.clientX - dragOffsetX) + 'px';
                frame.style.top = (e.clientY - dragOffsetY) + 'px';
            }

            function mouseUpHandler() {
                document.removeEventListener('mousemove', mouseMoveHandler);
                document.removeEventListener('mouseup', mouseUpHandler);
            }

            document.addEventListener('mousemove', mouseMoveHandler);
            document.addEventListener('mouseup', mouseUpHandler);
        });

        // Render list
        function renderList() {
            list.innerHTML = '';

            if (savedItems.length === 0) {
                const emptyMsg = document.createElement('div');
                emptyMsg.textContent = 'No saved items';
                emptyMsg.style.cssText = `
                    color: #999;
                    text-align: center;
                    padding: 10px;
                    font-style: italic;
                `;
                list.appendChild(emptyMsg);
                return;
            }

            savedItems.forEach((item, index) => {
                const itemDiv = document.createElement('div');
                itemDiv.style.cssText = `
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    padding: 5px;
                    margin: 3px 0;
                    background: rgba(255, 255, 255, 0.1);
                    border-radius: 3px;
                `;

                const nameSpan = document.createElement('span');
                nameSpan.textContent = item;
                nameSpan.style.cssText = `
                    color: white;
                    cursor: pointer;
                    flex: 1;
                    padding: 3px;
                `;

                // Search function
                nameSpan.onclick = () => searchItem(item);
                nameSpan.ondblclick = () => searchItem(item);

                // Delete button
                const deleteBtn = document.createElement('button');
                deleteBtn.textContent = '×';
                deleteBtn.style.cssText = `
                    background: #dc3545;
                    color: white;
                    border: none;
                    border-radius: 50%;
                    width: 18px;
                    height: 18px;
                    font-size: 10px;
                    cursor: pointer;
                    margin-left: 5px;
                `;
                deleteBtn.onclick = (e) => {
                    e.stopPropagation();
                    if (confirm(`Delete "${item}"?`)) {
                        savedItems.splice(index, 1);
                        saveItems(savedItems);
                        renderList();
                    }
                };

                itemDiv.appendChild(nameSpan);
                itemDiv.appendChild(deleteBtn);
                list.appendChild(itemDiv);
            });
        }

        // Search function
        function searchItem(item) {
            console.log('Searching:', item);

            // Find search field
            const searchFields = [
                document.querySelector('input[name="searchField"]'),
                document.querySelector('input[id*="search"]'),
                document.querySelector('input[placeholder*="Search"]'),
                document.querySelector('input[type="text"]')
            ].filter(Boolean);

            const searchField = searchFields[0];

            if (searchField) {
                searchField.value = item;

                // Trigger events
                searchField.dispatchEvent(new Event('input', { bubbles: true }));
                searchField.dispatchEvent(new Event('change', { bubbles: true }));

                // Find search button
                const searchButtons = [
                    document.querySelector('button[id*="search"]'),
                    document.querySelector('input[type="submit"]'),
                    document.querySelector('button[onclick*="search"]')
                ].filter(Boolean);

                const searchButton = searchButtons[0];

                if (searchButton) {
                    setTimeout(() => searchButton.click(), 100);
                }
            }
        }

        // Local storage functions
        function loadItems() {
            try {
                return JSON.parse(localStorage.getItem('simpleBookmarks')) || [];
            } catch {
                return [];
            }
        }

        function saveItems(items) {
            localStorage.setItem('simpleBookmarks', JSON.stringify(items));
        }
    }

})();