Open archive

11/21/2025, 1:04:55 AM

اعتبارا من 21-11-2025. شاهد أحدث إصدار.

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

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.

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

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Open archive
// @namespace   Violentmonkey Scripts
// @match       https://wplace.live/*
// @grant       none
// @version     1.0
// @author      nopeee
// @description 11/21/2025, 1:04:55 AM
// @license MIT
// ==/UserScript==

(function() {
  'use strict';

  const targetElement = document.querySelector("input[readonly='']");
  let openArchiveButton = null;

  const observer = new MutationObserver((mutations) => {
    const container = targetElement.parentNode;
    if (container) {
      const copyButton = container.querySelector('button.btn-primary');
      if (copyButton && !openArchiveButton) {
        openArchiveButton = document.createElement('button');
        openArchiveButton.textContent = 'Open Archive';
        openArchiveButton.classList.add('btn');
        openArchiveButton.classList.add('btn-primary');
        container.insertBefore(openArchiveButton, copyButton.nextSibling);

        openArchiveButton.addEventListener('click', () => {
          const inputValue = targetElement.value;
          const url = new URL(inputValue);
          const params = new URLSearchParams(url.search);
          const lat = params.get('lat');
          const lng = params.get('lng');
          const zoom = params.get('zoom');
          const archiveUrl = `https://wplace.samuelscheit.com/#lat=${lat}&lng=${lng}&zoom=${zoom}`;
          window.open(archiveUrl, '_blank');
        });
      } else if (copyButton && openArchiveButton) {
        // if button already exists, check if it's still in the correct position
        if (openArchiveButton.parentNode !== container) {
          container.insertBefore(openArchiveButton, copyButton.nextSibling);
        }
      } else if (!copyButton && openArchiveButton) {
        // if copy button is gone, remove open archive button
        openArchiveButton.remove();
        openArchiveButton = null;
      }
    }
  });

  observer.observe(targetElement.parentElement.parentElement, {
    childList: true,
  });
})();