PageSourceSearch

https://weather.metoffice.gov.uk/public/adhoc/mo-adhoc.js?77d9ca403b26a4ee51290a45bea6850b

js metoffice.gov.uk collected 2026-09-24 07:13:58 UTC 5,680 bytes, 156 lines download raw bytes

1"use strict";
2
3(function loadAdhocScripts() {
4    const logsEnabled = window.location.href.indexOf('adhoc=debug') !== -1;
5
6    const scripts = [
7        {
8            url: "/public/adhoc/covid-19-seasonal-advice-banner-message.js",
9            enabled: false
10        },
11        {
12            url: "/public/adhoc/covid-19-mountain-banner-message.js",
13            enabled: false
14        },
15        {
16            url: "/public/adhoc/data-outage-banner-message.js",
17            enabled: false
18        },
19        {
20            url: "/public/adhoc/redirect_old_search_to_new.js",
21            enabled: true,
22            pathnameMatch: [
23                {type: 'like', pathnames: ["^/public"]}
24            ]
25        },
26        { // load demo of mountain weather on our own page
27            url: "/public/pws/components/mountain/loader.js",
28            enabled: true,
29            pathnameMatch: [
30                {type: "exact", pathnames: ["/weather/guides/mountain/widget"]}
31            ]
32        }, {
33            url: "/public/adhoc/map-link-to-beta.js",
34            enabled: true,
35            pathnameMatch: [
36                {
37                    type: 'like', pathnames: [
38                        "^/public/weather/forecast/map",
39                        "^/public/weather/observation/map",
40                        "^/public/weather/observation/rainfall-radar"
41                    ]
42                }
43            ]
44        },
45        { // make logo black and white for period of national mourning
46            url: "/public/adhoc/mono-logo.js",
47            enabled: false
48        },
49        {
50            url: "/public/adhoc/resetAbVariants.js",
51            enabled: false
52        },
53        {
54            url: "/public/adhoc/mo-adhoc-gsc.js",
55            enabled: true
56        },
57        {
58            url: "/public/adhoc/strike-action-banner.js",
59            enabled: false,
60            pathnameMatch: [
61                {
62                    type: 'not like', pathnames: [
63                        "^/weather/maps-and-charts/rainfall-radar-forecast-map",
64                        "^/weather/maps-and-charts/temperature-map",
65                        "^/weather/maps-and-charts/wind-map",
66                        "^/weather/maps-and-charts/wind-gusts-map",
67                        "^/weather/maps-and-charts/precipitation-map",
68                        "^/weather/maps-and-charts/cloud-cover-map",
69                        "^/weather/maps-and-charts/uk-weather-map",
70                        "^/weather/maps-and-charts/rainfall-radar-forecast-accessible-colours-map"
71                    ]
72                }
73            ]
74        },
75        {
76            url: "/public/adhoc/set-expiry-cookie-control.js",
77            enabled: true
78        },
79    ];
80
81    function loadScript(url) {
82        let script = document.createElement("script");
83        script.src = url;
84        script.setAttribute("defer", "defer");
85        document.head.appendChild(script);
86    }
87
88    function hostMatch(adhoc) {
89        if (!adhoc.hostExactMatch || adhoc.hostExactMatch.length === 0)
90            return true;
91
92        // Searches array {adhoc.hostExactMatch} for the element that exactly matches {window.location.host}
93        // Returns true if found, false otherwise.
94        return adhoc.hostExactMatch.indexOf(window.location.host) !== -1;
95    }
96
97    function pathnameMatch(adhoc) {
98        if (!adhoc.pathnameMatch || adhoc.pathnameMatch.length === 0)
99            return true;
100        const pathname = window.location.pathname;
101        for (const matchRule of adhoc.pathnameMatch) {
102            if (!matchRule.pathnames)
103                continue;
104
105            switch (matchRule.type) {
106                case 'exact':
107                    // Searches array {matchRule.pathnames} for the element that exactly matches {pathname}.
108                    // Returns true if found, false otherwise.
109                    if (matchRule.pathnames.indexOf(pathname) !== -1) {
110                        logsEnabled && console.log('loadAdhocScripts:exact pathname match', matchRule, adhoc.url);
111                        return true;
112                    }
113                    break;
114                case 'like':
115                    for (const regex of matchRule.pathnames) {
116                        let re = new RegExp(regex);
117                        if (re.test(pathname)) {
118                            logsEnabled && console.log('loadAdhocScripts:like pathname match', regex, adhoc.url);
119                            return true;
120                        }
121                    }
122                    break;
123                case 'not like':
124                    let anyMatches = false;
125                    for (const regex of matchRule.pathnames) {
126                        let re = new RegExp(regex);
127                        if (re.test(pathname)) {
128                            logsEnabled && console.log('loadAdhocScripts:not like pathname match', regex, adhoc.url);
129                            anyMatches = true;
130                        }
131                    }
132                    return !anyMatches;
133            }
134        }
135
136        return false;
137    }
138
139    for (const adhocScript of scripts) {
140        if (!adhocScript.enabled)
141            continue;
142        if (!hostMatch(adhocScript)) {
143            logsEnabled && console.log('loadAdhocScripts:host does not match', adhocScript);
144            continue;
145        }
146        if (!pathnameMatch(adhocScript)) {
147            logsEnabled && console.log('loadAdhocScripts:pathname does not match', adhocScript);
148            continue;
149        }
150        logsEnabled && console.log('loadAdhocScripts: loading script', adhocScript.url);
151        loadScript(adhocScript.url);
152    }
153
154
155})();
156

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.