Compare commits
No commits in common. "main" and "dev" have entirely different histories.
@ -43,9 +43,6 @@ This project is licensed under the MIT License.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
- v1.1 31.07.2024
|
|
||||||
- added TP Session ID to Popup
|
|
||||||
- added Channels to Popup
|
|
||||||
- v1 05.07.2024*
|
- v1 05.07.2024*
|
||||||
- Initial Release
|
- Initial Release
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/***** Content JS for Chrome Extension: Tracking Proxy Helper *****/
|
/***** Content JS for Chrome Extension: Tracking Proxy Helper *****/
|
||||||
|
|
||||||
/*** Initialisation ***/
|
/*** Initialisation ***/
|
||||||
let tpdm = { activeTabId: null, activeWindowId: null, extInit: false, tpl: { tpId: '', sessId: '', eventCount: 0 } };
|
let tpdm = { activeTabId: null, activeWindowId: null, extInit: false, tpl: { tpId: '', eventCount: 0 } };
|
||||||
tpdm.data = tpdm.data || JSON.parse(JSON.stringify(tpdm.tpl));
|
tpdm.data = tpdm.data || JSON.parse(JSON.stringify(tpdm.tpl));
|
||||||
//console.log('content.js loaded');
|
//console.log('content.js loaded');
|
||||||
|
|
||||||
@ -25,8 +25,7 @@ window.addEventListener('message', function(event) {
|
|||||||
//console.log('Message received from injected script:', event);
|
//console.log('Message received from injected script:', event);
|
||||||
if (event.data.type === 'CHECK_TPT_RESULT') {
|
if (event.data.type === 'CHECK_TPT_RESULT') {
|
||||||
//console.log('Message received from injected script:', event);
|
//console.log('Message received from injected script:', event);
|
||||||
if (event.data.chaChanged) { chrome.runtime.sendMessage({ type: 'CHECK_TPT', chaChanged:true, tpobj:event.data.tpobj }); }
|
chrome.runtime.sendMessage({ type: 'CHECK_TPT', hasTPT: event.data.hasTPT, tpobj:event.data.tpobj });
|
||||||
else { chrome.runtime.sendMessage({ type: 'CHECK_TPT', hasTPT: event.data.hasTPT, hasSessID: event.data.hasSessID, tpobj:event.data.tpobj }); }
|
|
||||||
}
|
}
|
||||||
if (event.data.type === 'TRACKING_PROXY_RESPONSE') {
|
if (event.data.type === 'TRACKING_PROXY_RESPONSE') {
|
||||||
//console.log('Message received from injected TP script:', event);
|
//console.log('Message received from injected TP script:', event);
|
||||||
|
|||||||
@ -20,19 +20,9 @@ function getTPDetails() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Überprüfung des __tpt Objekts und Versendung des Ergebnisses
|
// Überprüfung des __tpt Objekts und Versendung des Ergebnisses
|
||||||
function checkTPT(obj) {
|
function checkTPT() {
|
||||||
if (typeof obj!='string') return;
|
|
||||||
if (window.__tpt && typeof window.__tpt.cha_str!='string') { window.__tpt.cha_str = ''; }
|
|
||||||
const tpDetails = getTPDetails();
|
const tpDetails = getTPDetails();
|
||||||
if (tpDetails.cha) {
|
sendTPmsg({ type: 'CHECK_TPT_RESULT', hasTPT: !!tpDetails.cid, tpobj: tpDetails });
|
||||||
if (JSON.stringify(tpDetails.cha)!=tpDetails.cha_str) {
|
|
||||||
sendTPmsg({ type: 'CHECK_TPT_RESULT', chaChanged:true, tpobj: tpDetails });
|
|
||||||
window.__tpt.cha_str = JSON.stringify(tpDetails.cha);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (obj=='cid' || obj=='fip') {
|
|
||||||
sendTPmsg({ type: 'CHECK_TPT_RESULT', hasTPT: !!tpDetails.cid, hasSessID: !!tpDetails.fip, tpobj: tpDetails });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy Handler zur Überwachung von Änderungen
|
// Proxy Handler zur Überwachung von Änderungen
|
||||||
@ -40,7 +30,9 @@ const handler = {
|
|||||||
set(target, property, value) {
|
set(target, property, value) {
|
||||||
target[property] = value;
|
target[property] = value;
|
||||||
debugLog(`Property ${property} changed to`, value);
|
debugLog(`Property ${property} changed to`, value);
|
||||||
checkTPT(property);
|
if (property === 'cid') {
|
||||||
|
checkTPT();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
get(target, property) {
|
get(target, property) {
|
||||||
@ -58,7 +50,7 @@ if (window.__tpt) {
|
|||||||
value = new Proxy(value, handler);
|
value = new Proxy(value, handler);
|
||||||
}
|
}
|
||||||
Object.defineProperty(this, '__tpt', { value, writable: true, configurable: true, enumerable: true });
|
Object.defineProperty(this, '__tpt', { value, writable: true, configurable: true, enumerable: true });
|
||||||
checkTPT('__tpt');
|
checkTPT();
|
||||||
},
|
},
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true
|
enumerable: true
|
||||||
@ -72,7 +64,7 @@ window.addEventListener('message', function(event) {
|
|||||||
//console.log('TRACKING_PROXY_REQUEST message 2', event);
|
//console.log('TRACKING_PROXY_REQUEST message 2', event);
|
||||||
const eventData = event.data.details.eventData;
|
const eventData = event.data.details.eventData;
|
||||||
const metaData = event.data.details.metaData;
|
const metaData = event.data.details.metaData;
|
||||||
if (eventData.cid && eventData.fip && window.__tpt && eventData.cid === window.__tpt.cid) {
|
if (eventData.cid && window.__tpt && eventData.cid === window.__tpt.cid) {
|
||||||
//console.log('Tracking Proxy Event detected:', event);
|
//console.log('Tracking Proxy Event detected:', event);
|
||||||
window.postMessage({ type: 'TRACKING_PROXY_RESPONSE', details: { eventData:eventData, metaData:metaData } }, '*');
|
window.postMessage({ type: 'TRACKING_PROXY_RESPONSE', details: { eventData:eventData, metaData:metaData } }, '*');
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +86,7 @@ setTimeout(() => {
|
|||||||
(function() {
|
(function() {
|
||||||
let tpid = '';
|
let tpid = '';
|
||||||
//console.log("inject.js loaded");
|
//console.log("inject.js loaded");
|
||||||
function checkTPT('1') {
|
function checkTPT() {
|
||||||
if (!window.__tpt) return;
|
if (!window.__tpt) return;
|
||||||
let tpobj = JSON.parse(JSON.stringify(window.__tpt));
|
let tpobj = JSON.parse(JSON.stringify(window.__tpt));
|
||||||
console.log('checkTPT result:', tpobj);
|
console.log('checkTPT result:', tpobj);
|
||||||
@ -102,12 +94,12 @@ setTimeout(() => {
|
|||||||
window.postMessage({ type: 'CHECK_TPT_RESULT', tpobj:tpobj }, '*');
|
window.postMessage({ type: 'CHECK_TPT_RESULT', tpobj:tpobj }, '*');
|
||||||
}
|
}
|
||||||
// Überprüfe sofort
|
// Überprüfe sofort
|
||||||
checkTPT('2');
|
checkTPT();
|
||||||
// Wiederhole die Überprüfung nach einer kurzen Verzögerung, um sicherzustellen, dass das Objekt geladen ist
|
// Wiederhole die Überprüfung nach einer kurzen Verzögerung, um sicherzustellen, dass das Objekt geladen ist
|
||||||
const observer = new MutationObserver((mutations, observer) => {
|
const observer = new MutationObserver((mutations, observer) => {
|
||||||
if (window.__tpt && window.__tpt.cid) {
|
if (window.__tpt && window.__tpt.cid) {
|
||||||
//console.log('TP is now available');
|
//console.log('TP is now available');
|
||||||
checkTPT('3');
|
checkTPT();
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Tracking Proxy Helper",
|
"name": "Tracking Proxy Helper",
|
||||||
"author": "andi@tracking-garden.com",
|
"author": "andi@tracking-garden.com",
|
||||||
"version": "1.1",
|
"version": "1",
|
||||||
"description": "This extension gives some information and options using the Tracking Proxy.",
|
"description": "This extension gives some information and options using the Tracking Proxy.",
|
||||||
"icons": {
|
"icons": {
|
||||||
//"16": "/img/get_started16.png",
|
//"16": "/img/get_started16.png",
|
||||||
|
|||||||
23
options.css
23
options.css
@ -99,27 +99,4 @@ button#add-url-field {
|
|||||||
color: #382d3d; /* Farbe für URL Match Labels */
|
color: #382d3d; /* Farbe für URL Match Labels */
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggle-header {
|
|
||||||
cursor: pointer;
|
|
||||||
color: #fe6845;
|
|
||||||
background-color: #382d3d;
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
display: inline-block;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dev-core .section {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dev-core .section {
|
|
||||||
background-color: #ccc7aa;
|
|
||||||
}
|
|
||||||
|
|
||||||
#httpheader {
|
|
||||||
padding: 20px;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|||||||
49
options.html
49
options.html
@ -6,11 +6,29 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Tracking Proxy Helper - Extension Options</title>
|
<title>Tracking Proxy Helper - Extension Options</title>
|
||||||
<link rel="stylesheet" href="options.css">
|
<link rel="stylesheet" href="options.css">
|
||||||
<script src="options.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Tracking Proxy Helper Settings</h1>
|
<h1>Tracking Proxy Helper Settings</h1>
|
||||||
<form id="options-form">
|
<form id="options-form">
|
||||||
|
<div class="section" id="httpheader">
|
||||||
|
<h2>HTTP Header for Dev.Environment</h2>
|
||||||
|
<p class="url-match-label">Notice: The HTTP Header Name is: <strong>Tp-Dev</strong></p>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="header-value">HTTP Header Value:</label>
|
||||||
|
<input type="text" id="header-value" name="header-value">
|
||||||
|
</div>
|
||||||
|
<strong class="url-match-label">URLs to match:</strong>
|
||||||
|
<div id="url-fields-container">
|
||||||
|
<div class="url-field">
|
||||||
|
<input type="text" class="url-input" name="url[]">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" class="regex-checkbox"> Is Regex
|
||||||
|
</label>
|
||||||
|
<button type="button" class="remove-url-field">Remove</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="add-url-field">Add URL Field</button>
|
||||||
|
</div>
|
||||||
<div class="section" id="blocking">
|
<div class="section" id="blocking">
|
||||||
<h2>JavaScript Injection and Blocking</h2>
|
<h2>JavaScript Injection and Blocking</h2>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -55,35 +73,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span onclick="toggleSection('dev-core')" class="toggle-header">+ Dev.Core</span>
|
|
||||||
<div class="section" id="dev-core">
|
|
||||||
<div id="httpheader" style="display:none;">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>HTTP Header Key:</label>
|
|
||||||
<input type="text" id="header-key" name="header-key" value="Tp-Dev">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>HTTP Header Value:</label>
|
|
||||||
<input type="text" id="header-value" name="header-value">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="header-global"> Add HTTP Header to all Requests (Notice: This will need more Resources)
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<strong class="url-match-label">URLs to match:</strong>
|
|
||||||
<div id="url-fields-container">
|
|
||||||
<div class="url-field">
|
|
||||||
<input type="text" class="url-input" name="url[]">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" class="regex-checkbox"> Is Regex
|
|
||||||
</label>
|
|
||||||
<button type="button" class="remove-url-field">Remove</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="button" id="add-url-field">Add URL Field</button>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Save</button>
|
<button type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
<h3>Saved Values</h3>
|
<h3>Saved Values</h3>
|
||||||
|
|||||||
26
options.js
26
options.js
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const form = document.getElementById('options-form');
|
const form = document.getElementById('options-form');
|
||||||
|
|
||||||
//const form = document.getElementById('options-form');
|
|
||||||
const addUrlButton = document.getElementById('add-url-field');
|
const addUrlButton = document.getElementById('add-url-field');
|
||||||
const urlFieldsContainer = document.getElementById('url-fields-container');
|
const urlFieldsContainer = document.getElementById('url-fields-container');
|
||||||
const savedValuesContainer = document.getElementById('saved-values');
|
const savedValuesContainer = document.getElementById('saved-values');
|
||||||
@ -51,9 +49,7 @@ function createUrlField() {
|
|||||||
* Save options to chrome.storage.sync
|
* Save options to chrome.storage.sync
|
||||||
*/
|
*/
|
||||||
function saveOptions() {
|
function saveOptions() {
|
||||||
const headerKey = document.getElementById('header-key').value;
|
|
||||||
const headerValue = document.getElementById('header-value').value;
|
const headerValue = document.getElementById('header-value').value;
|
||||||
const headerGlobal = document.getElementById('header-global').checked;
|
|
||||||
const urlFields = document.querySelectorAll('#httpheader .url-field'); // Only URL fields
|
const urlFields = document.querySelectorAll('#httpheader .url-field'); // Only URL fields
|
||||||
const urls = Array.from(urlFields).map(urlField => {
|
const urls = Array.from(urlFields).map(urlField => {
|
||||||
const urlInput = urlField.querySelector('.url-input');
|
const urlInput = urlField.querySelector('.url-input');
|
||||||
@ -61,7 +57,7 @@ function saveOptions() {
|
|||||||
|
|
||||||
// Ensure that the inputs exist
|
// Ensure that the inputs exist
|
||||||
if (!urlInput || !regexCheckbox) {
|
if (!urlInput || !regexCheckbox) {
|
||||||
//console.error('Invalid URL field:', urlField);
|
console.error('Invalid URL field:', urlField);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +78,7 @@ function saveOptions() {
|
|||||||
const blockTrackingProxy = document.getElementById('block-tracking-proxy').checked;
|
const blockTrackingProxy = document.getElementById('block-tracking-proxy').checked;
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
headerKey,
|
|
||||||
headerValue,
|
headerValue,
|
||||||
headerGlobal,
|
|
||||||
urls,
|
urls,
|
||||||
scriptContent,
|
scriptContent,
|
||||||
scriptUrl,
|
scriptUrl,
|
||||||
@ -96,7 +90,7 @@ function saveOptions() {
|
|||||||
trackingProxyUrlIsRegex,
|
trackingProxyUrlIsRegex,
|
||||||
blockTrackingProxy
|
blockTrackingProxy
|
||||||
}, function () {
|
}, function () {
|
||||||
//alert('Options saved!');
|
alert('Options saved!');
|
||||||
displaySavedValues(); // Update displayed saved values
|
displaySavedValues(); // Update displayed saved values
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -106,9 +100,7 @@ function saveOptions() {
|
|||||||
*/
|
*/
|
||||||
function loadOptions() {
|
function loadOptions() {
|
||||||
chrome.storage.sync.get([
|
chrome.storage.sync.get([
|
||||||
'headerKey',
|
|
||||||
'headerValue',
|
'headerValue',
|
||||||
'headerGlobal',
|
|
||||||
'urls',
|
'urls',
|
||||||
'scriptContent',
|
'scriptContent',
|
||||||
'scriptUrl',
|
'scriptUrl',
|
||||||
@ -120,9 +112,7 @@ function loadOptions() {
|
|||||||
'trackingProxyUrlIsRegex',
|
'trackingProxyUrlIsRegex',
|
||||||
'blockTrackingProxy'
|
'blockTrackingProxy'
|
||||||
], function (data) {
|
], function (data) {
|
||||||
document.getElementById('header-key').value = data.headerKey || 'Tp-Dev';
|
|
||||||
document.getElementById('header-value').value = data.headerValue || '';
|
document.getElementById('header-value').value = data.headerValue || '';
|
||||||
document.getElementById('header-global').checked = data.headerGlobal || false;
|
|
||||||
|
|
||||||
const urlFieldsContainer = document.getElementById('url-fields-container');
|
const urlFieldsContainer = document.getElementById('url-fields-container');
|
||||||
urlFieldsContainer.innerHTML = '';
|
urlFieldsContainer.innerHTML = '';
|
||||||
@ -158,16 +148,4 @@ function displaySavedValues() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleSection(sectionId) {
|
|
||||||
const section = document.getElementById(sectionId);
|
|
||||||
const toggleHeader = document.querySelector('.toggle-header');
|
|
||||||
if (section.style.display === 'none') {
|
|
||||||
section.style.display = '';
|
|
||||||
toggleHeader.textContent = '- Dev.Core';
|
|
||||||
} else {
|
|
||||||
section.style.display = 'none';
|
|
||||||
toggleHeader.textContent = '+ Dev.Core';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
12
popup.css
12
popup.css
@ -61,24 +61,24 @@ pre {
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.events, .channels {
|
.events {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-details, .channel-details {
|
.event-details {
|
||||||
color: #382d3d;
|
color: #382d3d;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-details summary, .channel-details summary {
|
.event-details summary {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #382d3d; /* Dunkelviolett für Event-Namen */
|
color: #382d3d; /* Dunkelviolett für Event-Namen */
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-details pre, .channel-details pre {
|
.event-details pre {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
color: #382d3d;
|
color: #382d3d;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@ -88,11 +88,11 @@ pre {
|
|||||||
font-family: monospace; /* Schriftart für bessere Lesbarkeit von JSON */
|
font-family: monospace; /* Schriftart für bessere Lesbarkeit von JSON */
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-details pre .key, .channel-details pre .key {
|
.event-details pre .key {
|
||||||
color: #fe6845; /* Orange für JSON-Schlüssel/Eigenschaftsnamen */
|
color: #fe6845; /* Orange für JSON-Schlüssel/Eigenschaftsnamen */
|
||||||
}
|
}
|
||||||
|
|
||||||
.event-details pre .string, .event-details pre .number, .channel-details pre .string, .channel-details pre .number {
|
.event-details pre .string, .event-details pre .number {
|
||||||
color: #382d3d; /* Dunkelviolett für Werte im JSON */
|
color: #382d3d; /* Dunkelviolett für Werte im JSON */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,10 +11,6 @@
|
|||||||
<a href="#" id="options-link">Settings</a>
|
<a href="#" id="options-link">Settings</a>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<p><span class="label">Account ID:</span> <span id="tp-id" class="value">No Tracking Proxy detected</span></p>
|
<p><span class="label">Account ID:</span> <span id="tp-id" class="value">No Tracking Proxy detected</span></p>
|
||||||
<p><span class="label">TP Session:</span> <span id="tp-sess-id" class="value">No Tracking Proxy detected</span></p>
|
|
||||||
<p>
|
|
||||||
<div id="channels" class="channels"></div>
|
|
||||||
</p>
|
|
||||||
<p>
|
<p>
|
||||||
<span class="label">Events:</span>
|
<span class="label">Events:</span>
|
||||||
<div id="events" class="events"></div>
|
<div id="events" class="events"></div>
|
||||||
|
|||||||
15
popup.js
15
popup.js
@ -26,28 +26,13 @@ function syntaxHighlight(json) {
|
|||||||
// Initialize popup with Tracking Proxy Events
|
// Initialize popup with Tracking Proxy Events
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const tpIdElement = document.getElementById('tp-id');
|
const tpIdElement = document.getElementById('tp-id');
|
||||||
const sessIdElement = document.getElementById('tp-sess-id');
|
|
||||||
const channelsElement = document.getElementById('channels');
|
|
||||||
const eventsElement = document.getElementById('events');
|
const eventsElement = document.getElementById('events');
|
||||||
|
|
||||||
chrome.runtime.sendMessage({ type: 'REQUEST_POPUP_DATA' }, function(response) {
|
chrome.runtime.sendMessage({ type: 'REQUEST_POPUP_DATA' }, function(response) {
|
||||||
//test(response);
|
//test(response);
|
||||||
if (typeof response=='object') {
|
if (typeof response=='object') {
|
||||||
// TP Account ID
|
|
||||||
const tpId = response.tpId || 'Not Available';
|
const tpId = response.tpId || 'Not Available';
|
||||||
tpIdElement.textContent = tpId;
|
tpIdElement.textContent = tpId;
|
||||||
// TP Session ID
|
|
||||||
const sessId = response.sessId || 'Not Available';
|
|
||||||
sessIdElement.textContent = sessId;
|
|
||||||
// Channels
|
|
||||||
const channels = response.channels || [];
|
|
||||||
channelsElement.innerHTML = `
|
|
||||||
<details class="channel-details">
|
|
||||||
<summary>Channels</summary>
|
|
||||||
<pre>${syntaxHighlight(JSON.stringify(channels, null, 2))}</pre>
|
|
||||||
</details>
|
|
||||||
`;
|
|
||||||
// Events
|
|
||||||
const events = response.events || [];
|
const events = response.events || [];
|
||||||
eventsElement.innerHTML = events.map((event, index) => `
|
eventsElement.innerHTML = events.map((event, index) => `
|
||||||
<details class="event-details">
|
<details class="event-details">
|
||||||
|
|||||||
18
worker.js
18
worker.js
@ -1,7 +1,7 @@
|
|||||||
/***** Service Worker JS for Chrome Extension: Tracking Proxy Helper *****/
|
/***** Service Worker JS for Chrome Extension: Tracking Proxy Helper *****/
|
||||||
|
|
||||||
/*** Initialisation ***/
|
/*** Initialisation ***/
|
||||||
let tpdm = { activeTabId: null, activeWindowId: null, extInit: false, tpl: { tpId:'', sessId:'', channels:[], eventCount:0, events:[] } };
|
let tpdm = { activeTabId: null, activeWindowId: null, extInit: false, tpl: { tpId:'', eventCount:0, events:[] } };
|
||||||
//tpdm.data = tpdm.data || JSON.parse(JSON.stringify(tpdm.tpl));
|
//tpdm.data = tpdm.data || JSON.parse(JSON.stringify(tpdm.tpl));
|
||||||
tpdm.data = tpdm.data || {};
|
tpdm.data = tpdm.data || {};
|
||||||
//console.log('Worker loaded');
|
//console.log('Worker loaded');
|
||||||
@ -205,17 +205,11 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||||||
getCurrentTabId((tabId) => {
|
getCurrentTabId((tabId) => {
|
||||||
tpdm.activeTabId = tabId;
|
tpdm.activeTabId = tabId;
|
||||||
//console.log('CHECK_TPT (Tab: '+tabId+'):', message);
|
//console.log('CHECK_TPT (Tab: '+tabId+'):', message);
|
||||||
if (message.chaChanged) {
|
if (message.hasTPT) {
|
||||||
tpdm.data[tabId].channels = message.tpobj.cha;
|
|
||||||
} else if (message.hasSessID) {
|
|
||||||
tpdm.data[tabId].sessId = message.tpobj.fip;
|
|
||||||
} else if (message.hasTPT) {
|
|
||||||
tpdm.data.eventCount = 0;
|
tpdm.data.eventCount = 0;
|
||||||
resetBadge(tabId);
|
resetBadge(tabId);
|
||||||
if (typeof tpdm.data[tabId]!='object') tpdm.data[tabId] = JSON.parse(JSON.stringify(tpdm.tpl));
|
if (typeof tpdm.data[tabId]!='object') tpdm.data[tabId] = JSON.parse(JSON.stringify(tpdm.tpl));
|
||||||
tpdm.data[tabId].tpId = message.tpobj.cid;
|
tpdm.data[tabId].tpId = message.tpobj.cid;
|
||||||
tpdm.data[tabId].sessId = message.tpobj.fip;
|
|
||||||
tpdm.data[tabId].channels = message.tpobj.cha;
|
|
||||||
} else {
|
} else {
|
||||||
clearBadge(tabId);
|
clearBadge(tabId);
|
||||||
}
|
}
|
||||||
@ -232,12 +226,10 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||||||
if (typeof tpdm.data[tpdm.activeTabId]!='object') tpdm.data[tpdm.activeTabId] = JSON.parse(JSON.stringify(tpdm.tpl));
|
if (typeof tpdm.data[tpdm.activeTabId]!='object') tpdm.data[tpdm.activeTabId] = JSON.parse(JSON.stringify(tpdm.tpl));
|
||||||
let obj = {
|
let obj = {
|
||||||
tpId: tpdm.data[tpdm.activeTabId].tpId,
|
tpId: tpdm.data[tpdm.activeTabId].tpId,
|
||||||
sessId: tpdm.data[tpdm.activeTabId].sessId,
|
|
||||||
tabId: tpdm.activeTabId,
|
tabId: tpdm.activeTabId,
|
||||||
channels: tpdm.data[tpdm.activeTabId].channels,
|
|
||||||
events: tpdm.data[tpdm.activeTabId].events
|
events: tpdm.data[tpdm.activeTabId].events
|
||||||
};
|
};
|
||||||
//console.log('TP Received message:'+tpdm.data[tpdm.activeTabId].sessId, JSON.parse(JSON.stringify(tpdm.data[tpdm.activeTabId])));
|
//console.log('TP Received message:'+tpdm.data[tpdm.activeTabId].tpId, obj);
|
||||||
sendResponse(obj);
|
sendResponse(obj);
|
||||||
//});
|
//});
|
||||||
} else {
|
} else {
|
||||||
@ -304,8 +296,8 @@ chrome.webRequest.onBeforeRequest.addListener(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!eventData || !eventData.fip) {
|
if (!eventData || !eventData.cid) {
|
||||||
//console.log('Payload has no fip:', details);
|
//console.log('Payload has no cid:', details);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let metaData = { documentId:details.documentId, frameId:details.frameId, initiator:details.initiator, requestId:details.requestId, tabId:details.tabId, timeStamp:details.timeStamp, url:details.url };
|
let metaData = { documentId:details.documentId, frameId:details.frameId, initiator:details.initiator, requestId:details.requestId, tabId:details.tabId, timeStamp:details.timeStamp, url:details.url };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user