Created
May 18, 2026 00:06
-
-
Save easrng/f9fa048dbd181bee9d3f3935ca9ab903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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