Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed for current Google Maps version #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuro68k
Copy link

@kuro68k kuro68k commented Dec 4, 2019

Class names changed.
Click() no longer works.
Use cache of deleted images to avoid repeatedly deleting the same one.

Class names changed.
Click() no longer works.
Use cache of deleted images to avoid repeatedly deleting the same one.
@doeti
Copy link

doeti commented Dec 7, 2019

worked with my photos, but not the reviews

@kuro68k
Copy link
Author

kuro68k commented Dec 8, 2019

Ah, I didn't use it on reviews. I'll make some and have a look.

@lorepirri
Copy link
Owner

Hi there!
Thanks a lot for spotting the issue and having it fixed!
However. I think I would split the fix in two if you don't mind (selectors update, and simplifying the idx system).

True idx is not needed probably, but if this is the case, maybe also cache is not really needed.

The classes changed, but updating the selectors, make everything work (also for reviews).

I notice a language flaw also (for comparing innerHtml with a specific label, dependant on the current user's language).

I'm pushing some updates on master.

Copy link
Owner

@lorepirri lorepirri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the selectors, they work with reviews and photos, without changing anything else,
however, you are right about removing idx from the equation, but also your idcache would not needed then,
if you feel like you could update your code pulling from the current master and find a solution without idx and idcache (have a look at other more recent scripts I wrote for cleaning FB).

Comment on lines +18 to +20
var evt = document.createEvent('MouseEvent');
evt.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(evt);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the intention here, but actually if one chose correctly the selector with the element having the "click" event handler set, then the .click() will work

var confirmDeleteContribution = function(idx) {
[...document.querySelectorAll('button[class~="blue-button-text"]')].forEach( (a) => {
var confirmDeleteContribution = function() {
[...document.querySelectorAll('button[class~="section-dialog-footer-action-button"]')].forEach( (a) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous selector blue-button-text is still working for me.

are there different versions of maps around maybe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it works for me too, I didn't need to change it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so no need to use section-dialog-footer-action-button then

[...document.querySelectorAll('div[class~="context-menu-entry"] div[class~="context-menu-entry-text"]')].forEach( (a) => {

var deleteContribution = function() {
[...document.querySelectorAll('div[class~="action-menu-entry"] div[class~="action-menu-entry-text"]')].forEach( (a) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this has to change, correct

Comment on lines +40 to +58
var elem;
var found = false;
var z = -1;
do {
z++;
elem = [...document.querySelectorAll('button[aria-label*="actions"]')][z];
if (elem == null)
return;
found = true;
for (var i = 0; i < idcache.length; i++)
{
if (idcache[i] == elem.getAttribute("data-photo-id"))
found = false;
}
} while(found == false);

if (elem) {
idcache.push(elem.getAttribute("data-photo-id"));
console.log(elem.getAttribute("data-photo-id"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmh I don't understand this part,
photo makes it valid only for the photos and not reviews,
in general comments on what the loop does are highly appreciated

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the selector button[aria-label*="actions" is not working now,
I updated it on master with 'button[class*="action-menu"]'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I had was that when the script runs it deleted a couple of photos and then got stuck. To reproduce you need to have at least 3 photos of one location to delete. The first one would be deleted but then the others wouldn't slide into place and the script would keep trying to delete the first one.

The issue seems to be that they don't remove the deleted photo's elements, just hide them, so it was still item [0] in the list. Unfortunately the behaviour isn't consistent so you can't just iterate, so I created the ID cache to just skip over ones that have already been deleted.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks a lot for explanation, it makes sense then,
now I understand the need of idcache and why probably I added the idx thing last year.
let me see if there is a way of not looping but include all the photos in the main list.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, actually idx was meant for that purpose,
have a look at current master,
thanks a lot again for contributing to this!

Comment on lines +69 to +70
var idcache = new Array();
idcache.push("none");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that idx is not really needed, but also idcache then.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah it turns out that idx is needed (have a look at the above comments)

@lorepirri
Copy link
Owner

worked with my photos, but not the reviews

the current updated master works also with reviews, at today

@kuro68k
Copy link
Author

kuro68k commented Dec 8, 2019

Thanks for looking at this. I don't really know Javascript, I was just annoyed by Google stealing my Rewards money so I wanted to withdraw all my support.

Can confirm it now works but it only deletes the first 10 entries. If you have more than 10 entries you have to manually run it again until they are all gone. My version keeps going until there are none left, I don't know if that was your intended behaviour.

Correction: It deletes however many are displayed, which by default is 10 when I switch to that tab. So to be clear after a few have been deleted the site loads more reviews, and they are not deleted.

@lorepirri
Copy link
Owner

yes it deletes the reviews/photos that are rendered in that moment: scroll down until the last review/photo is shown and then start the script

@kuro68k
Copy link
Author

kuro68k commented Dec 9, 2019

Okay, well I tested it out with one minor modification, I removed the test for currentIndex < numberOfItems and just checked that elem was valid, then it deleted all my reviews. Of course your method works and may be better, as I say I'm a C guy and not an expert on JS. Thanks for fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants