Skip to content

Commit

Permalink
Update consent manager tag for manual
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Nov 18, 2024
1 parent 242b760 commit 98a36a4
Showing 1 changed file with 167 additions and 6 deletions.
173 changes: 167 additions & 6 deletions manual/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

gtag('config', 'G-YMW4X5CSKP');
</script>
<!-- See https://www.quantcast.com/protect/sites username is email -->
<!-- Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->
<!-- InMobi Choice. Consent Manager Tag v3.0 (for TCF 2.2) -->
<script type="text/javascript" async=true>
(function() {
var host = window.location.hostname;
var element = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];
var url = 'https://cmp.quantcast.com'
.concat('/choice/', '593Yp13RM2k2D', '/', host, '/choice.js?tag_version=V2');
var url = 'https://cmp.inmobi.com'
.concat('/choice/', '593Yp13RM2k2D', '/', host, '/choice.js?tag_version=V3');
var uspTries = 0;
var uspTriesLimit = 3;
element.async = true;
Expand Down Expand Up @@ -81,7 +80,7 @@
}
} else {
if(args[0] === 'init' && typeof args[3] === 'object') {
args[3] = Object.assign(args[3], { tag_version: 'V2' });
args[3] = Object.assign(args[3], { tag_version: 'V3' });
}
queue.push(args);
}
Expand Down Expand Up @@ -147,6 +146,168 @@

makeStub();

function makeGppStub() {
const CMP_ID = 10;
const SUPPORTED_APIS = [
'2:tcfeuv2',
'6:uspv1',
'7:usnatv1',
'8:usca',
'9:usvav1',
'10:uscov1',
'11:usutv1',
'12:usctv1'
];

window.__gpp_addFrame = function (n) {
if (!window.frames[n]) {
if (document.body) {
var i = document.createElement("iframe");
i.style.cssText = "display:none";
i.name = n;
document.body.appendChild(i);
} else {
window.setTimeout(window.__gpp_addFrame, 10, n);
}
}
};
window.__gpp_stub = function () {
var b = arguments;
__gpp.queue = __gpp.queue || [];
__gpp.events = __gpp.events || [];

if (!b.length || (b.length == 1 && b[0] == "queue")) {
return __gpp.queue;
}

if (b.length == 1 && b[0] == "events") {
return __gpp.events;
}

var cmd = b[0];
var clb = b.length > 1 ? b[1] : null;
var par = b.length > 2 ? b[2] : null;
if (cmd === "ping") {
clb(
{
gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
cmpStatus: "stub", // possible values: stub, loading, loaded, error
cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
signalStatus: "not ready", // possible values: not ready, ready
supportedAPIs: SUPPORTED_APIS, // list of supported APIs
cmpId: CMP_ID, // IAB assigned CMP ID, may be 0 during stub/loading
sectionList: [],
applicableSections: [-1],
gppString: "",
parsedSections: {},
},
true
);
} else if (cmd === "addEventListener") {
if (!("lastId" in __gpp)) {
__gpp.lastId = 0;
}
__gpp.lastId++;
var lnr = __gpp.lastId;
__gpp.events.push({
id: lnr,
callback: clb,
parameter: par,
});
clb(
{
eventName: "listenerRegistered",
listenerId: lnr, // Registered ID of the listener
data: true, // positive signal
pingData: {
gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
cmpStatus: "stub", // possible values: stub, loading, loaded, error
cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
signalStatus: "not ready", // possible values: not ready, ready
supportedAPIs: SUPPORTED_APIS, // list of supported APIs
cmpId: CMP_ID, // list of supported APIs
sectionList: [],
applicableSections: [-1],
gppString: "",
parsedSections: {},
},
},
true
);
} else if (cmd === "removeEventListener") {
var success = false;
for (var i = 0; i < __gpp.events.length; i++) {
if (__gpp.events[i].id == par) {
__gpp.events.splice(i, 1);
success = true;
break;
}
}
clb(
{
eventName: "listenerRemoved",
listenerId: par, // Registered ID of the listener
data: success, // status info
pingData: {
gppVersion: "1.1", // must be “Version.Subversion”, current: “1.1”
cmpStatus: "stub", // possible values: stub, loading, loaded, error
cmpDisplayStatus: "hidden", // possible values: hidden, visible, disabled
signalStatus: "not ready", // possible values: not ready, ready
supportedAPIs: SUPPORTED_APIS, // list of supported APIs
cmpId: CMP_ID, // CMP ID
sectionList: [],
applicableSections: [-1],
gppString: "",
parsedSections: {},
},
},
true
);
} else if (cmd === "hasSection") {
clb(false, true);
} else if (cmd === "getSection" || cmd === "getField") {
clb(null, true);
}
//queue all other commands
else {
__gpp.queue.push([].slice.apply(b));
}
};
window.__gpp_msghandler = function (event) {
var msgIsString = typeof event.data === "string";
try {
var json = msgIsString ? JSON.parse(event.data) : event.data;
} catch (e) {
var json = null;
}
if (typeof json === "object" && json !== null && "__gppCall" in json) {
var i = json.__gppCall;
window.__gpp(
i.command,
function (retValue, success) {
var returnMsg = {
__gppReturn: {
returnValue: retValue,
success: success,
callId: i.callId,
},
};
event.source.postMessage(msgIsString ? JSON.stringify(returnMsg) : returnMsg, "*");
},
"parameter" in i ? i.parameter : null,
"version" in i ? i.version : "1.1"
);
}
};
if (!("__gpp" in window) || typeof window.__gpp !== "function") {
window.__gpp = window.__gpp_stub;
window.addEventListener("message", window.__gpp_msghandler, false);
window.__gpp_addFrame("__gppLocator");
}
};

makeGppStub();

var uspStubFunction = function() {
var arg = arguments;
if (typeof window.__uspapi !== uspStubFunction) {
Expand All @@ -173,7 +334,7 @@
}
})();
</script>
<!-- End Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->
<!-- End InMobi Choice. Consent Manager Tag v3.0 (for TCF 2.2) -->
<script data-cfasync="false" type="text/javascript">
var freestar = freestar || {};
freestar.hitTime = Date.now();
Expand Down

0 comments on commit 98a36a4

Please sign in to comment.