Skip to content

Commit

Permalink
Fix: Close any type of modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Geczy committed Feb 10, 2021
1 parent 63c410e commit b10630d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion manifest.json

This file was deleted.

10 changes: 5 additions & 5 deletions src/automations/Swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Swiper {
matchFound = () => {
const found = document.querySelectorAll('button[aria-label="Close"]');

if (!found || !found.length) {
if (typeof found?.click !== 'function') {
return false;
}

Expand Down Expand Up @@ -84,12 +84,12 @@ class Swiper {
}, 100);
}

if (this.interactions.closeInstructions(this.run)) {
return;
if (this.interactions.closeInstructions()) {
return setTimeout(this.run, generateRandomNumber());
}

if (this.interactions.closeSuperLike(this.run)) {
return;
if (this.interactions.closeModal()) {
return setTimeout(this.run, generateRandomNumber());
}

if (!this.canSwipe()) {
Expand Down
12 changes: 6 additions & 6 deletions src/misc/Interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Interactions {
}
};

closeInstructions = (cb) => {
closeInstructions = () => {
// Homescreen modal blocks us
try {
if (document.querySelector('[data-testid="addToHomeScreen"]')) {
Expand All @@ -40,12 +40,12 @@ class Interactions {
} catch (e) {}
};

closeSuperLike = (cb) => {
// "Upgrade your like" modal blocks us
closeModal = () => {
try {
if (document.querySelector('#modal-manager [aria-label="⭐"]')) {
document.querySelector('#modal-manager button:nth-of-type(2)').click();
logger('Closing upgrade super like modal');
const modal = document.querySelector('#modal-manager');
if (modal) {
document.querySelector('#modal-manager > div').click();
logger('Closing modal');
cb();
return true;
}
Expand Down

0 comments on commit b10630d

Please sign in to comment.