PageSourceSearch

https://cidade.fm/scripts/inmobi-choice.js?2.1

js cidade.fm collected 2026-10-01 12:39:33 UTC 10,490 bytes, 332 lines download raw bytes

1// InMobi Choice. Consent Manager Tag v3.0 (for TCF 2.2)
2(function() {
3  // SO EM PRODUCAO. Antes isto corria em todos os hosts: punha a barra de
4  // cookies no dev-cidadefm.bmap.pt e no .local, e a configuracao do CMP
5  // esta registada para o dominio cidade.fm, nao para esses.
6  // O criterio e o MESMO do temCmp() do includes/pubs-and-metrics.inc e os
7  // dois tem de continuar a concordar: se este ficheiro nao carregar o CMP
8  // num host onde o gate acha que ha consentimento a espera, a pub nunca
9  // liga; se carregar num host onde o gate acha que nao ha, aparece uma
10  // barra de cookies em staging. Por isso, ao mexer aqui, mexer la.
11  var h = window.location.hostname;
12  if (h.indexOf('.local') !== -1 || h.indexOf('dev-') === 0 || h.indexOf('.bmap.pt') !== -1) return;
13
14  var host = 'cidade.fm';
15  var element = document.createElement('script');
16  var firstScript = document.getElementsByTagName('script')[0];
17  var url = 'https://cmp.inmobi.com'.concat('/choice/', 'E-Sa-J6PnL1F7', '/', host, '/choice.js?tag_version=V3');
18  var uspTries = 0;
19  var uspTriesLimit = 3;
20  element.async = true;
21  element.type = 'text/javascript';
22  element.src = url;
23
24  firstScript.parentNode.insertBefore(element, firstScript);
25
26  function makeStub() {
27    var TCF_LOCATOR_NAME = '__tcfapiLocator';
28    var queue = [];
29    var win = window;
30    var cmpFrame;
31
32    function addFrame() {
33      var doc = win.document;
34      var otherCMP = !!(win.frames[TCF_LOCATOR_NAME]);
35
36      if (!otherCMP) {
37        if (doc.body) {
38          var iframe = doc.createElement('iframe');
39
40          iframe.style.cssText = 'display:none';
41          iframe.name = TCF_LOCATOR_NAME;
42          doc.body.appendChild(iframe);
43        } else {
44          setTimeout(addFrame, 5);
45        }
46      }
47      return !otherCMP;
48    }
49
50    function tcfAPIHandler() {
51      var gdprApplies;
52      var args = arguments;
53
54      if (!args.length) {
55        return queue;
56      } else if (args[0] === 'setGdprApplies') {
57        if (
58          args.length > 3 &&
59          args[2] === 2 &&
60          typeof args[3] === 'boolean'
61        ) {
62          gdprApplies = args[3];
63          if (typeof args[2] === 'function') {
64            args[2]('set', true);
65          }
66        }
67      } else if (args[0] === 'ping') {
68        var retr = {
69          gdprApplies: gdprApplies,
70          cmpLoaded: false,
71          cmpStatus: 'stub'
72        };
73
74        if (typeof args[2] === 'function') {
75          args[2](retr);
76        }
77      } else {
78        if(args[0] === 'init' && typeof args[3] === 'object') {
79          args[3] = Object.assign(args[3], { tag_version: 'V3' });
80        }
81        queue.push(args);
82      }
83    }
84
85    function postMessageEventHandler(event) {
86      var msgIsString = typeof event.data === 'string';
87      var json = {};
88
89      try {
90        if (msgIsString) {
91          json = JSON.parse(event.data);
92        } else {
93          json = event.data;
94        }
95      } catch (ignore) {}
96
97      var payload = json.__tcfapiCall;
98
99      if (payload) {
100        window.__tcfapi(
101          payload.command,
102          payload.version,
103          function(retValue, success) {
104            var returnMsg = {
105              __tcfapiReturn: {
106                returnValue: retValue,
107                success: success,
108                callId: payload.callId
109              }
110            };
111            if (msgIsString) {
112              returnMsg = JSON.stringify(returnMsg);
113            }
114            if (event && event.source && event.source.postMessage) {
115              event.source.postMessage(returnMsg, '*');
116            }
117          },
118          payload.parameter
119        );
120      }
121    }
122
123    while (win) {
124      try {
125        if (win.frames[TCF_LOCATOR_NAME]) {
126          cmpFrame = win;
127          break;
128        }
129      } catch (ignore) {}
130
131      if (win === window.top) {
132        break;
133      }
134      win = win.parent;
135    }
136    if (!cmpFrame) {
137      addFrame();
138      win.__tcfapi = tcfAPIHandler;
139      win.addEventListener('message', postMessageEventHandler, false);
140    }
141  };
142
143  makeStub();
144
145  function makeGppStub() {
146    const CMP_ID = 10;
147    const SUPPORTED_APIS = [
148      '2:tcfeuv2',
149      '6:uspv1',
150      '7:usnatv1',
151      '8:usca',
152      '9:usvav1',
153      '10:uscov1',
154      '11:usutv1',
155      '12:usctv1'
156    ];
157
158    window.__gpp_addFrame = function (n) {
159      if (!window.frames[n]) {
160        if (document.body) {
161          var i = document.createElement("iframe");
162          i.style.cssText = "display:none";
163          i.name = n;
164          document.body.appendChild(i);
165        } else {
166          window.setTimeout(window.__gpp_addFrame, 10, n);
167        }
168      }
169    };
170    window.__gpp_stub = function () {
171      var b = arguments;
172      __gpp.queue = __gpp.queue || [];
173      __gpp.events = __gpp.events || [];
174
175      if (!b.length || (b.length == 1 && b[0] == "queue")) {
176        return __gpp.queue;
177      }
178
179      if (b.length == 1 && b[0] == "events") {
180        return __gpp.events;
181      }
182
183      var cmd = b[0];
184      var clb = b.length > 1 ? b[1] : null;
185      var par = b.length > 2 ? b[2] : null;
186      if (cmd === "ping") {
187        clb(
188          {
189            gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
190            cmpStatus: "stub", // possible values: stub, loading, loaded, error
191            cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
192            signalStatus: "not ready", // possible values: not ready, ready
193            supportedAPIs: SUPPORTED_APIS, // list of supported APIs
194            cmpId: CMP_ID, // IAB assigned CMP ID, may be 0 during stub/loading
195            sectionList: [],
196            applicableSections: [-1],
197            gppString: "",
198            parsedSections: {},
199          },
200          true
201        );
202      } else if (cmd === "addEventListener") {
203        if (!("lastId" in __gpp)) {
204          __gpp.lastId = 0;
205        }
206        __gpp.lastId++;
207        var lnr = __gpp.lastId;
208        __gpp.events.push({
209          id: lnr,
210          callback: clb,
211          parameter: par,
212        });
213        clb(
214          {
215            eventName: "listenerRegistered",
216            listenerId: lnr, // Registered ID of the listener
217            data: true, // positive signal
218            pingData: {
219              gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
220              cmpStatus: "stub", // possible values: stub, loading, loaded, error
221              cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
222              signalStatus: "not ready", // possible values: not ready, ready
223              supportedAPIs: SUPPORTED_APIS, // list of supported APIs
224              cmpId: CMP_ID, // list of supported APIs
225              sectionList: [],
226              applicableSections: [-1],
227              gppString: "",
228              parsedSections: {},
229            },
230          },
231          true
232        );
233      } else if (cmd === "removeEventListener") {
234        var success = false;
235        for (var i = 0; i < __gpp.events.length; i++) {
236          if (__gpp.events[i].id == par) {
237            __gpp.events.splice(i, 1);
238            success = true;
239            break;
240          }
241        }
242        clb(
243          {
244            eventName: "listenerRemoved",
245            listenerId: par, // Registered ID of the listener
246            data: success, // status info
247            pingData: {
248              gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
249              cmpStatus: "stub", // possible values: stub, loading, loaded, error
250              cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
251              signalStatus: "not ready", // possible values: not ready, ready
252              supportedAPIs: SUPPORTED_APIS, // list of supported APIs
253              cmpId: CMP_ID, // CMP ID
254              sectionList: [],
255              applicableSections: [-1],
256              gppString: "",
257              parsedSections: {},
258            },
259          },
260          true
261        );
262      } else if (cmd === "hasSection") {
263        clb(false, true);
264      } else if (cmd === "getSection" || cmd === "getField") {
265        clb(null, true);
266      }
267      //queue all other commands
268      else {
269        __gpp.queue.push([].slice.apply(b));
270      }
271    };
272    window.__gpp_msghandler = function (event) {
273      var msgIsString = typeof event.data === "string";
274      try {
275        var json = msgIsString ? JSON.parse(event.data) : event.data;
276      } catch (e) {
277        var json = null;
278      }
279      if (typeof json === "object" && json !== null && "__gppCall" in json) {
280        var i = json.__gppCall;
281        window.__gpp(
282          i.command,
283          function (retValue, success) {
284            var returnMsg = {
285              __gppReturn: {
286                returnValue: retValue,
287                success: success,
288                callId: i.callId,
289              },
290            };
291            event.source.postMessage(msgIsString ? JSON.stringify(returnMsg) : returnMsg, "*");
292          },
293          "parameter" in i ? i.parameter : null,
294          "version" in i ? i.version : "1.1"
295        );
296      }
297    };
298    if (!("__gpp" in window) || typeof window.__gpp !== "function") {
299      window.__gpp = window.__gpp_stub;
300      window.addEventListener("message", window.__gpp_msghandler, false);
301      window.__gpp_addFrame("__gppLocator");
302    }
303  };
304
305  makeGppStub();
306
307  var uspStubFunction = function() {
308    var arg = arguments;
309    if (typeof window.__uspapi !== uspStubFunction) {
310      setTimeout(function() {
311        if (typeof window.__uspapi !== 'undefined') {
312          window.__uspapi.apply(window.__uspapi, arg);
313        }
314      }, 500);
315    }
316  };
317
318  var checkIfUspIsReady = function() {
319    uspTries++;
320    if (window.__uspapi === uspStubFunction && uspTries < uspTriesLimit) {
321      console.warn('USP is not accessible');
322    } else {
323      clearInterval(uspInterval);
324    }
325  };
326
327  if (typeof window.__uspapi === 'undefined') {
328    window.__uspapi = uspStubFunction;
329    var uspInterval = setInterval(checkIfUspIsReady, 6000);
330  }
331})();
332// End InMobi Choice. Consent Manager Tag v3.0 (for TCF 2.2)

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.