Art Monthly fix

remove markers for galleries that do not have shows

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
	}
})();