WaitForKeyElements (); - Stop running script in popup in Chrome Extension?

This question is a continuation of another question in which I had to ask and demand a new post, so excuse me if I am talking about things that may be unclear without reading another question.

When using the waitForKeyElements () utility, I ran into a problem in which a div included inside a small pop-up window contained in the same URL. Currently my extension works on Twitter , and I intend for the div contained on the profile pages (e.g. http://twitter.com/todayshow ) to move over another div on the page. I do this through waitForKeyElements() due to some loading problems that are resolved with this utility.

However, on the profile page, you can click the link to another username that pulls out a small window (inside one window / tab at the same URL), where information about them and several previous tweets are displayed. The problem here is that the same div appears in the pop-up window, and then it moves to the main page behind the pop-up window, where this should not be. This can be stopped on the profile page by connecting the false parameter to waitForKeyElements() , however, on the non-profile page, you can still activate this pop-up window, which then moves to the main page, since the div I want to move it higher on the profile page that still exists here, which causes obvious problems.

I am wondering if there is a way around this, as errors in Chrome prevented me from excluding these pages. So far (just a brainstorm) I think:

  • on the page where the div does not exist to start, create an empty value that means false will handle the problem.
  • somehow stopping the script from firing at the given URL, although due to the way Twitter works, it would have to track OnClick() and the page URL (I think) that I'm not sure how to do this.
  • stop working when a popup appears, but I have no idea where to start.

Any help is appreciated. Any necessary code related to this question can be found in the first two links, and the problem I am facing can be seen by a quick visit to Twitter.

EDIT: When you enable the false parameter, it works when you go directly to profiles through the URL bar, if you are in the profile and use the link to access the profile, the script is not inserted and my extension does not work. Thus, it will also require permission or an alternative method.

0
source share
1 answer

I had a brain wave in which I could use insertAfter() to insert the <div> that I originally moved before, after the <div> that I originally moved. This <div> missing from the popup, which means that nothing moves to the back page when it should not.

Regarding the previous question, my code is now simple:

 waitForKeyElements ( "jQuery selector for div(s) you want to move", // Opposite to what it was. moveSelectDivs ); function moveSelectDivs (jNode) { jNode.insertAfter ("APPROPRIATE JQUERY SELECTOR"); // Again, the opposite. } 

This solves the problem I am facing, and my extension is now working fine, however, I will leave this question published if someone comes back to it in the future.

0
source

All Articles