Skip to content

Commit

Permalink
Merge pull request #10 from katie-ta/kta--gdpr-applies
Browse files Browse the repository at this point in the history
[#5] add state for gdprApplies
  • Loading branch information
katie-ta authored Oct 16, 2021
2 parents 3b6a6f1 + cf46fb6 commit 0c643bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/content_scripts/uCookie.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable no-underscore-dangle */
/* global chrome */
/* global browser */

const TCF_VERSION_NUMBER = 2;

let api;
Expand Down
18 changes: 13 additions & 5 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* global chrome */
/* global browser */

let api;
if (chrome == undefined) {
if (chrome === undefined) {
api = browser;
} else {
api = chrome;
Expand All @@ -24,7 +27,7 @@ function fetch_data() {
} else {
message = { call: 'getTCData', manual: false };
}
api.tabs.sendMessage(tabs[0].id, message, handle_response);
api.tabs.sendMessage(tabs[0].id, message, handleResponse);
} catch (error) {
console.log('popup.js: error caught', error);
}
Expand Down Expand Up @@ -101,9 +104,9 @@ function update_with_consent_string_data(consent_string) {
}
}

function handle_response(message) {
if (message == undefined || message.response == null) { return; }
if (message.response == 'found') {
function handleResponse(message) {
if (!message || !message.response) { return; }
if (message.response === 'found') {
cmpLocatorFound = true;
fetch_data();
try {
Expand All @@ -114,7 +117,12 @@ function handle_response(message) {
}
return;
}

const res = message.response;
if (res.gdprApplies === false) {
document.getElementById('gdpr_applies_false').classList.remove('hidden');
document.getElementById('cmplocator_found').classList.add('hidden');
}
console.log(res);
if (res.tcString) {
consent_string = decodeConsentString(res.tcString);
Expand Down
8 changes: 8 additions & 0 deletions src/popup/ucookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<div id="cmplocator_found" class="hidden">
<p>A CMP on this webpage implements IAB Europe's Transparency and Consent Framework.<br />Waiting for an answer from CMP... (We may not get one before you close the cookie banner)</p>
</div>
<div id="gdpr_applies_false" class="hidden">
<p>
A CMP on this webpage implements IAB Europe's Transparency and Consent Framework. However, the CMP has determined that GDPR does not apply in this context. If you are not residing in the EU, try using a VPN.
<br/>
<br/>
Find more information <a target="_blank" href="https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#what-does-the-gdprapplies-value-mean">here</a>.
</p>
</div>
<div id="cmp_content" class="hidden">
The consent string registered by the CMP on this page contains the following information:<br />
CMP: <span id='cmp'></span><span id='cmpid'></span><br />
Expand Down

0 comments on commit 0c643bd

Please sign in to comment.