Skip to content

Commit

Permalink
use postmessage to grab object id
Browse files Browse the repository at this point in the history
  • Loading branch information
codemist committed Aug 3, 2022
1 parent 75dbf5d commit c1fae24
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function positionIframe(fencePos) {

// console.log(`${fencePosition.x}px`);
// iframeObject.style.marginLeft = "100px";
console.log(fencePosition);
// console.log(fencePosition);
// console.log("this works");
}

Expand All @@ -360,6 +360,13 @@ function openLoginPrompt(socialAction, fencePos, htmlBadgeDiv, target) {
// console.log("iframe added");
positionIframe(fencePos);

window.addEventListener("message", (e) => {
if (e.data === "allowTriggered") {
target.click();
}
});


} else {
hasFbcWrapper.remove();
}
Expand Down Expand Up @@ -897,9 +904,7 @@ function escapeKeyListener () {
window.addEventListener("click", function() {
if (this.document.querySelector(".fbc-wrapper")) {
closeIframe();
console.log("check");
}
console.log("check 2");
});


Expand Down
36 changes: 32 additions & 4 deletions src/inpage-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const url = window.location.href;
const action = parseQuery(url).action;
const btnLink = parseQuery(url).btnlink;

console.log(action);


const loginItem = document.getElementById("fbc-login");
const emailItem = document.getElementById("fbc-email");

Expand Down Expand Up @@ -63,11 +60,42 @@ fbcPromptAllow.addEventListener("click", (e) => {
message: "add-domain-to-list"
});

parent.location.href = btnLink;
// console.log(btnLink);

// if (typeof btnLink === "string") {
// // parent.location.href = btnLink;
// console.log("this string");
// }

// if (typeof btnLink === "object") {
// console.log("this obj");
// }

parent.postMessage("allowTriggered", "*");

});

fbcPromptCancel.addEventListener("click", function() {
parent.postMessage("closeTheInjectedIframe", "*")
});


// target.addEventListener("click", (e) => {
// if (!e.isTrusted) {
// // The click was not user generated so ignore
// return false;
// }

// if (allowClickSwitch) {
// // Button disabled. Either will trigger new HTTP request or page will refresh.
// setTimeout(()=>{
// location.reload(true);
// }, 250);
// return;
// } else {
// // Click badge, button disabled
// e.preventDefault();
// // e.stopPropagation();
// openLoginPrompt("login", htmlBadgeFragmentFenceDiv.parentElement, htmlBadgeDiv, target);
// }
// });

0 comments on commit c1fae24

Please # to comment.