Open archive

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

Stan na 21-11-2025. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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