Skip to content

Instantly share code, notes, and snippets.

@easrng
Created May 18, 2026 00:06
Show Gist options
  • Select an option

  • Save easrng/f9fa048dbd181bee9d3f3935ca9ab903 to your computer and use it in GitHub Desktop.

Select an option

Save easrng/f9fa048dbd181bee9d3f3935ca9ab903 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Show Transit on Booking.com
// @namespace https://easrng.net
// @match https://www.booking.com/*
// @grant none
// @version 1.0
// @author -
// @description Shows the Google Maps transit layer on Booking.com maps.
// @run-at document-start
// ==/UserScript==
(function () {
"use strict";
function defineTrap(parent, prop, callback) {
let value;
Object.defineProperty(parent, prop, {
configurable: true,
enumerable: true,
get: () => value,
set: (newValue) => {
value = newValue;
callback(value);
},
});
}
defineTrap(window, "google", (google) => {
defineTrap(google, "maps", (maps) => {
defineTrap(maps, "Map", (OriginalMap) => {
if (OriginalMap.__isProxy) return;
const MapProxy = function (div, options) {
options.mapId = null;
const instance = new OriginalMap(div, options);
const transitLayer = new google.maps.TransitLayer();
transitLayer.setMap(instance);
return instance;
};
MapProxy.__isProxy = true;
Object.setPrototypeOf(MapProxy, OriginalMap);
MapProxy.prototype = OriginalMap.prototype;
maps.Map = MapProxy;
});
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment