Art Monthly fix

remove markers for galleries that do not have shows

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Art Monthly fix
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  remove markers for galleries that do not have shows
// @author       Enrico Costanza
// @match        https://www.artmonthly.co.uk/magazine/site/london-gallery-map
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';
    'esversion: 9';

    // remove markers
    for (const [key, value] of Object.entries(map._layers)) {
        console.log(`${key}: ${value._icon}`);
        if (value._icon !== undefined) {
            map.removeLayer(value);
        }
    }

    // loop through the array and add a marker for each
    // only add markers for galleries that have shows
    for (var i = 0; i < galleries.length; i++) {
        //console.log(galleries[i][4]);
        if (galleries[i][4] === undefined) {
            continue;
        }
        if (galleries[i][4].includes(' to ') === false) {
            continue;
        }
        marker = new L.marker([galleries[i][1], galleries[i][2], galleries[i][0]], {icon: galleryIcon})
            .bindPopup(galleries[i][4], PopupClass)
            .bindTooltip(galleries[i][0], {permanent: true, ...TooltipClass})
            .openTooltip()
            .addTo(map);
	}
})();