I have written a script in jQuery which takes a web site’s source code, goes through it and extracts all the forms then displays the HTML on my site. An unexpected side effect of this is there are 3rd party cookies being set, which absolutely cannot happen. The main culprit, from what I can ascertain, are HubSpot images and what is most annoying is it seems I don’t even have to output the results on my page for the cookies to appear. This is how I am getting the source code:
let getCode = function(file) {
$.get(file, formAcc);
};
getCode(‘/source-code.txt’);
and then, in the ‘formAcc’ function:
$(‘form’, code).each(function() {});So, if I comment out the above function, I don’t get cookies, but just having that code, not actually using it to populate accordions on the page, is enough to see the cookies in DevTools. I’m fairly good at JavaScript, but not an expert. I have used ‘debugger’ to go through the process line by line. The site is built using Tabler and the point where the cookies are set is in a part of the code that comes compiled with that and I don’t understand it. I’ll post the entire function in case it points to where I’m going wrong.
export function contentAccordions() {
let formAcc = function(code) {
let formLength = code.match(/ 0) {
$(‘#sc-content-panel’).append(
‘
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
Forms (‘+ formLength +’)‘+ moreInfoArrow +’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
);
$(‘form’, code).each(function() {});
};
let parser = new DOMParser();
let codeParser = parser.parseFromString(code, ‘text/html’);
$(codeParser).find(‘style’).remove();
$(codeParser).find(‘script’).remove();
$(codeParser).find(‘noscript’).remove();
let codeParserText = codeParser.body.innerHTML.replace(//g,” “).replace(/ +/g,” “).replace(/ns*ns*n/g, ‘nn’);
$(‘#sc-content-panel’).append(
‘
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
Home Page Text’
+’
‘
+”
+”
+”
+”
+’
‘
+’
‘
+’
‘
+’
‘
+’
'+ codeParserText +'
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
+’
‘
);
};
let getCode = function(file) {
$.get(file, formAcc);
};
getCode(‘/source-code.txt’);
};
TIA