siteMapPerso
Changes
mySiteMap.js 75(+53 -22)
Details
mySiteMap.js 75(+53 -22)
diff --git a/mySiteMap.js b/mySiteMap.js
index b154381..068ea84 100644
--- a/mySiteMap.js
+++ b/mySiteMap.js
@@ -56,6 +56,10 @@ let payWallListeners = [
{ class: `.footer-footer a:nth-child(2)`, labelName: 'Botón Precios vigentes from Pay Wall' },
]
+let articleListeners = [
+ { class: `nav.breadcrumb ol li a span`, labelName: 'Breadcrumb:' },
+]
+
let homeInteractions = {
name: "Home"
}
@@ -64,14 +68,17 @@ let payWallInteractions = {
name: "PayWall"
}
-const home = new PageType("Home", "cronista.com", homeInteractions, homeListeners);
-const payWall = new PageType("PayWall", `cronista.com/suscripciones`, payWallInteractions, payWallListeners);
-//const article = new PageType("Article", `article`, payWallInteractions, payWallListeners);
+let articleInteractions = {
+ name: "Article"
+}
+const home = new PageType("Home", "cronista.com", homeInteractions, homeListeners, false);
+const payWall = new PageType("PayWall", `cronista.com/suscripciones`, payWallInteractions, payWallListeners, false);
+const article = new PageType("Article", window.location.href, articleInteractions, articleListeners, document.querySelector("#pagecontent .news"));
function Pages() {
- return [home, payWall]
+ return [home, payWall, article]
}
//
@@ -111,7 +118,7 @@ SalesforceInteractions.init({
SalesforceInteractions.initSitemap(sitemapConfig);
});
-function PageType(name, myUrl, interaction, myEvents) {
+function PageType(name, myUrl, interaction, myEvents, isArticle) {
this.name = name;
this.interaction = interaction;
this.isMatch = () => {
@@ -124,32 +131,56 @@ function PageType(name, myUrl, interaction, myEvents) {
} else {
console.log('La URL NO termina con "/"');
}
-
- isMatch = (url === `${enviroment}${myUrl}` ? true : false);
+ if (isArticle) {
+ console.log('El elemento existe:', isArticle);
+ isMatch = true
+ } else {
+ console.log('El elemento no fue encontrado');
+ isMatch = (url === `${enviroment}${myUrl}` ? true : false);
+ }
console.log(url)
console.log(isMatch)
+
return isMatch;
};
this.listeners = GenerateListeners(name, myEvents);
if (name == "PayWall") {
this.onActionEvent = (actionEvent) => {
- let limit = new URL(window.location.href).searchParams.get("limit")
- actionEvent.user = actionEvent.user || {};
- actionEvent.user.attributes = actionEvent.user.attributes || {};
- console.log("limit: " + limit)
- console.log(typeof (limit))
- if (limit != null) {
- const isLimit = limit === 'true';
- actionEvent.user.attributes.typeOfEntry = !isLimit ? "choque exclusivo" : "choque metered";
- let continueUrl = new URL(window.location.href).searchParams.get("continue")
- actionEvent.user.attributes.continueUrl = continueUrl;
- } else {
- actionEvent.user.attributes.typeOfEntry = "Choque directo";
- }
-
- return actionEvent;
+ return PayWallActions(actionEvent);
}
}
+ if (isArticle) {
+ this.onActionEvent = (actionEvent) => {
+ return ArticleActions(actionEvent);
+ }
+ }
+}
+
+function ArticleActions(actionEvent) {
+ actionEvent.user = actionEvent.user || {};
+ actionEvent.user.attributes = actionEvent.user.attributes || {};
+ actionEvent.user.attributes.authorName = document.querySelector("h3.authortitle a").innerText;
+ actionEvent.user.attributes.publishDate = document.querySelector('.author-date time').getAttribute('datetime');
+ actionEvent.user.attributes.articleId = document.querySelector('input[name="i"]').value;
+ actionEvent.user.attributes.accessCondition = document.querySelector('meta[name="paywal"]').getAttribute('content');
+ actionEvent.user.attributes.canonicalUrl = document.querySelector('link[rel="canonical"]').href;
+ return actionEvent;
+}
+
+function PayWallActions(actionEvent) {
+ let limit = new URL(window.location.href).searchParams.get("limit")
+ actionEvent.user = actionEvent.user || {};
+ actionEvent.user.attributes = actionEvent.user.attributes || {};
+ if (limit != null) {
+ const isLimit = limit === 'true';
+ actionEvent.user.attributes.typeOfEntry = !isLimit ? "choque exclusivo" : "choque metered";
+ let continueUrl = new URL(window.location.href).searchParams.get("continue")
+ actionEvent.user.attributes.continueUrl = continueUrl;
+ } else {
+ actionEvent.user.attributes.typeOfEntry = "Choque directo";
+ }
+
+ return actionEvent;
}
function ReadHomeBlocks(event) {