Make site/tab think it's in focus - javascript

I'm developing a Chrome extension which updates a tab with a URLs in LinkedIn (every some times it changes the URL). The problem is that URLs in LinkedIn don't fully load until the user is focused on that site/tab, and I need the page to load when the user is using other tabs as well.
So is there any way I can use JavaScript (either using Chrome's background script, or a content script which will execute in the required tab) to make LinkedIn think the page is in focus, so that it loads fully?

Related

How to inject text from browser extension to web page?

I am creating a Firefox extension with React.js and want to inject a text into the active website. The permissions, content_script and background script are set in manifest.json but the problem is I do not understand the concept how it should work.
So far I tried to add content script but that runs a script at page load and thats it. The background does not seem to interact with the page.
I need a script that listen for an event, when I click on a button in the extension popup, it should send the text from the React app to update the site. Basically like a password manager when you injecting the password into the form field.
Can someone tell me the concept as I do not get what case relevant to my problem after checking in and out the web extension documentation?

Chrome Extension: Is there a way to execute popup.js before clicking on the extension icon?

What I'm trying to do:
I'm building a chrome extension that has a popup, an options page, and content scripts. So far, I'm able to store preferences set on the options page and get them using popup.js. The popup.js makes a couple of public API calls to get some information X.
What I'm stuck on:
I need to be able to run/execute popup.js when the DOM loads, before the extension icon is clicked, so that information X can be injected into the DOM via the content scripts.
My question:
Is there a way to execute popup.js before clicking on the extension icon? (Right now, the content scripts loads fine displaying information X, after the the extension icon is clicked)
chrome.storage is fully supported for content scripts, so there is no need to communicate the user preferences from the options page to the content scripts via popup.js or background.js.
With this in mind, I'm able to access user preferences directly to make the API calls in the content scripts, using storage.sync

chrome extension opens with page load

I need to create a chrome extension that for every web page te he user opens - he will have a button on top of the page (similar to the google translate extension - just that it will appear with page load, without the need to press a button) - preessing on it will do some activity.
from what i saw - the way to do it is to create a content script that will add an iframe that includes the button on the window.onload. just before i do that - i want to be sure there is no more simple way of doing that.
Thanks.
There is an experimental infobar API, but it's unknown when, if ever, it becomes stable.
As-is, you really need to inject your UI into the page DOM from a content script, with an iframe being a good solution to separate your UI from the page.
If it's just a button for each page then you could use a Browser Action
If you'd like for it to actually be in the page then an iframe is a good way to go.

How do pageActions and browserActions differ?

I'm a writing a chrome extension that allows users to do the following:
Load data into the popup when the icon is clicked
Change the data in the popup based on actions the user takes on the page
Append elements to the DOM of the page based on actions taken in the popup
It seems that I can accomplish 1 with a script in the browser_action field of the manifest, but perhaps I need a page_action script for 2 and 3?
The core of the problem is that I do not know exactly how browser_actions and page_actions differ from each other. My limited understanding is that page actions allow data populated in the popup to be manipulated dynamically. Is this true? I cannot find an explanation about the differences that makes sense to me.
Browser Action is a type of extensions that use icon on the right of address bar. You click on that icon and popup page is loading. Those extensions work regardless of page currently opened.
Page Action only works while certain webpage(s) is opened. It displays as an icon inside the address bar (near page URL). This is for extensions only working on certain websites.
If you want to make your extension working on every website, you should use browser_action.
For further information you may want to visit these pages:
http://developer.chrome.com/extensions/browserAction.html
http://developer.chrome.com/extensions/pageAction.html

How can I remove an iframe within an iframe on an external web page like Pinterest's bookmarklet?

I am in the process of making a bookmarklet that allows users to highlight text on an external web page.
It runs JavaScript code that appends a JavaScript file from my server to the current web page that takes the title of the current web page, the URL of the current web page, and then the highlight text of the current web page. Finally, the user would click a button to submit the data to my web server to be saved into the database.
I have two ways of doing this: (1) have a popup with the data in the URL as parameters, or (2) to have an iframe inserted into the current web page with a form to submit the data.
In the one with the popup (1), the users browser auto blocks the popup for every domain. How do I get around this? It seems like Facebook share and twitter tweet buttons bypass the popup blocker though...
In the one with the iframe (2), I want to remove the iframe from the DOM after submitting data. However, if I'm on another domain, I get an error saying I am denied access because of origin policy something. I know it's possible because Pinterest's bookmarklet does this, it inserts an iframe then removes it from the current DOM.
I am looking for information on how these solutions work, so I can do something similar with my bookmarklet.
I resolved this by adding a post message callback after saving the data from the iframe.

Categories

Resources