Skip to content

Commit

Permalink
Fix prerender js errors
Browse files Browse the repository at this point in the history
  • Loading branch information
amits97 committed Aug 25, 2024
1 parent 9a6f253 commit d391d48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "naadan-chords",
"version": "0.83.0",
"version": "0.83.5",
"homepage": "https://www.naadanchords.com/",
"private": true,
"dependencies": {
Expand Down
12 changes: 11 additions & 1 deletion prerender/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,17 @@ export async function handler(event) {
url.searchParams.append("isPrerendered", true);
await page.goto(url.href);

//remove layout breaking ads
// Remove google ads script tags
await page.evaluate(() => {
var elements = document.querySelectorAll("script");
for (let i = 0; i < elements.length; i++) {
if (elements[i].src.includes("googlesyndication")) {
elements[i].parentNode.removeChild(elements[i]);
}
}
});

// remove layout breaking ads
let elementClassToRemove = ".ad, .google-auto-placed";

await page.evaluate((sel) => {
Expand Down

0 comments on commit d391d48

Please sign in to comment.