Сhecking data updates on the site using a chrome extension - javascript

I am trying to create a chrome extension, one of the functions of which will be to check for the appearance of new data on the site after clicking the start button in a pop-up window.
Our site has a table in which new data appears from time to time, we need to receive in chrome.storage only those data that appeared on the site after pressing the start button, and stop receiving after pressing the stop button.
Maybe someone knows some APIs for writing such functionality, or maybe some functions for it, I would be grateful for any advice?

you can use MutationObserver, but configure it carefully to watch only required nodes

Related

Javascript bring a tab to the front

I am writing a Javascript which runs in the browser using Tampermonkey.
The logic in the script is as follows.
1. Do some checks.
2. If a certain condition is met, then trigger an alert box in the browser.
Currently the alert box is shown in the browser tab, but amidst multiple tabs, the user does not notice the alert box till they navigate to the tab.
I am trying to figure out one or both of the following.
1. Bring the tab to the front i.e. focus on that tab.
2. Do something more aggressive than the alert box to catch user's attention. I thought of things such as playing sounds etc but it requires on user's speakers being on etc.
Any ideas on how to make this work would be greatly appreciated.
Looks like this cannot be done and the easiest option would be to write some data to the browser's local storage and then open a new window, fetch the data and display it.

Load testing with Asp.net site- issue regarding database entry

I want to load test one scenario for the load testing a ASP.net site.
There is one grid of records that contain kind of scorecards.
When user Click on view for any one record, new Tab will open with that scorecard detail. And in which user can select Review or Dispute radio button and simply submit the form.But when user click on the Submit button, one pop up comes with the OK button in it. And when user click on the OK it will close the newly open Tab(score card detail) and update/refresh the that Grid page.
So while recording of the scenario when I click on the submit button I am not getting any confirmation pop-up(as Jmeter is not able to execute Java script). and also there is no database entry for that form submission.
This scenario is working fine in normal user actions(without Jmeter).
While recording I can also see the Request recorded for Form submission but not reflected in database.
I am not sure if this is because of the limitation of the Jmeter of inability to execute Java script or something related to Proxy settings.
But after the talk with the developers they said before the java script alert, another code/method is executed for database entry. So could not figure it out what exactly the problem is SO looking for some help from you guys.
jmeter- during its execution runs in non-ui mode while java script is used for basic validations and making the user interface comfortable
a better approach or a solution is to have a chat with the developer to disable the pop up and complete the action without a popup (or a button within browser itself in case of any dependency of button to execute the functionality) in your local environment to proceed further

Is there any way to detect popup close for a Chrome Extension before the popup is closed?

I know that one can use ports to detect popup close. However, this doesn't work when there is information on the popup that I wish to persist.
For this extension I need to be able to save the textarea contents to sync storage when the popup is closed. There already is an update button which manages this, but no way to temporarily halt and save the status if the popup gets (accidentally) closed.
One way to do this is to keep storing the content on keypress, but I'd rather not hit the storage so often (especially since it's connected to some other event handlers).
Is there any way I can mimic onbeforeunload for a popup without being too heavy on the I/O?
All extension pages (background page, browser action popups, etc.) share the same process and get direct script access to each other via chrome.extension.getBackgroundPage / chrome.extension.getViews, so one thing you could try is having an onbeforeunload event in your popup which grabs a handle to the background page and passes over any javascript data to the background page, and then have it do the serialization. You can even hand over a chunk of DOM by using document.adoptNode.
In general though we encourage more of a "save as you go after a few seconds of user idle" approach to writing extensions and apps, because your code can unexpectedly stop running for lots of reasons (entire browser or OS crash, loss of power, etc.). Obviously this is harder in cases where you have a big data structure to save, because you then have to start looking at how to do incremental save, etc.
Use localStorage to save the data and setPopup to save the page see here Keep a chrome extension popup after close it

disable onclick ads with a content-script in Google Chrome

There are some video streaming sites that pop up an ad anytime you click anywhere on the page. The problem is, you have to click on the page to press play! So I was thinking of making a UserScript that disables the script that does this. The only problem is, I already disable all the scripts on the site and when I do it still pops up. Is there a way that I can disable them ? I'm also using jQuery, so if I can do it through their interface, that would be great.
edit: Two perfect examples of such sites are daclips.in and gorrilavid.in
I have Adblocker Plus, and it seems like it is not recognizing "on Click" events as pop-ups, rather normal clicked links. And the logic is simple, no Adblocker will block you from clicking something intentionally and it (the link) opening in another window/tab.
The problem is the new window contains your clicked Url, while the original window/tab "Refreshes" (i.e. redirects) to another url.
Advertising companies seem to use this trick to bypass adblocking software.
Just ditch Chrome and use Firefox. Firefox already have built-in mouse-click popups. I think all addons like Adguard or Adblock can not disable mouse-click popups. If you use Firefox, these are the steps:
Type about:config in the browser's address bar and hit the enter key.
First time users need to confirm that they be careful on the next page.
Type or paste dom.popup_allowed_events into the search field.
The value of the preference highlights all events that are allowed to spawn popups.
Edit the value to remove some or all of the items here.
Why not just use a browser extension such as AdBlock?
https://chrome.google.com/webstore/detail/adblock/gighmmpiobklfepjocnamgkkbiglidom?hl=en
My go-to is right click and open in new tab. onClick events only happen with a left click. It's cumbersome but it still ends up being less work than closing the pop-up and whatever annoying prompts it may have.
I do not there's a practical solution for this.
Moreover, I think some of the answers here are missing the specific case in OP, where clicking anywhere on the page will cause the pop up to happen, not just clicking on links. According to this, neither right-clicking then choosing "open", nor noticing and blocking the target URL will help. I do not know of an add blocker that helps here either, because it's not trivial to meaningfully filter a click event that is taking place on the whole page object.
Only the solution provided by #Monkey would work, at the drawback of possibly breaking other things.

javascript button click casuing Internet Explorer secuirty exception

I have a application that allows a user to choose some parameters for a powerpoint report, run the report, then allow the user to "save" or "open" the powerpoint file. I got all of that working OK. When you click on "run" report, it pops open a window which generates the report, stores it in session, then closes the window. I have a button on the main page that will export the report.
So, now, when the pop up window that generates the report is finished, i use "window.opener" to call a javascript method on the main page, that will do a javascript click of the button. when this button is pressed, Internet Explorer gives me the following message : "To help protect your security, Internet Explorer blocked this site from downloading files to your computer.."
Do you guys know of any tricks around this?
The browser doesn't like it when you try to make a download happen from some context other than a user-triggered event (like a "click"; maybe only a "click"). The user can adjust the security setting, but obviously that's not a solution for most people.
Really the only thing I know to do is to re-think the way that users interact with your pages, so that you can make sure that only actions invoked directly from button clicks (like, URLs that are the targets of form submits, for example) return a download. It's a pain.

Categories