Skip to content

Commit

Permalink
remove console log e script do pixel do codigo
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueVilela committed Sep 29, 2022
1 parent adc6b44 commit f5c3fe9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
5 changes: 2 additions & 3 deletions front/src/app/components/main-page/main-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import { InjectCustomScriptService } from '../../services/custom-script/inject-c
export class MainPageComponent implements OnInit, AfterViewInit {


script = '<script>console.log(\'script da pagina secundaria executando\');</script>';
script = '<script>console.log(\'script da pagina principal executando\');</script>';

constructor(
public injectCustomScriptService: InjectCustomScriptService
) {}

ngOnInit(): void {
console.log("Você entrou na pagina secundaria");
console.log('garai',this.script);
console.log("Você entrou na pagina principal");
this.injectCustomScriptService.setScriptToHeader(this.script)
}

Expand Down
22 changes: 1 addition & 21 deletions front/src/app/components/sub-page/sub-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,14 @@ import { InjectCustomScriptService } from 'src/app/services/custom-script/inject
})
export class SubPageComponent implements OnInit, AfterViewInit {

script = `
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '457526166340322');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=457526166340322&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->
`;
script = `<script>console.log(\'script da pagina secundaria executando\');</script>`;

constructor(
public injectCustomScriptService: InjectCustomScriptService
) {}

ngOnInit(): void {
console.log("Você entrou na pagina secundaria");
console.log('garai',this.script);
// this.injectCustomScriptService.setScriptToHeader(this.script)
this.injectCustomScriptService.setScriptToBody(this.script)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ export class InjectCustomScriptService {
) { }

public setScriptToBody(data: string): void {
console.log(document.getElementsByClassName("script_personalizado").length);
console.log(document.getElementsByClassName("script_personalizado_body").length);
if (document.getElementsByClassName("script_personalizado").length === 0) {
$(data).toArray().forEach(element => {
if (element.tagName === "SCRIPT" || element.tagName === "NOSCRIPT") {
element.classList.add("script_personalizado");
element.classList.add("script_personalizado_body");
$("body").append(element);
}
});
}
}

public setScriptToHeader(data: string): void {
if (document.getElementsByClassName("script_personalizado").length === 0) {
if (document.getElementsByClassName("script_personalizado_header").length === 0) {
$(data).toArray().forEach(element => {
if (element.tagName === "SCRIPT" || element.tagName === "NOSCRIPT") {
element.classList.add("script_personalizado");
element.classList.add("script_personalizado_header");
$("head").append(element);
}
});
Expand Down

0 comments on commit f5c3fe9

Please sign in to comment.