Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5] add state for gdprApplies #10

Merged
merged 3 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
Comment on lines +2 to +3
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this to resolve errors, since chrome and browser aren't explicitly defined


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) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== is safer

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) { 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
9 changes: 9 additions & 0 deletions src/popup/ucookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
<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