I need to build Google Chrome plugin, what will track all clicks on all links on all pages.
After click on link, instead of page opening plugin must catch click, plugin must obtain href attribute of the clicked link, change something in this URL and open page with new, changed URL.
Is it possible to make?
With the Content Scripts you can pass your own JS library into any (or particular) page, intersect clicks and prevent defaults (with regular JS API) and finally you can pass link back to the background page and use chrome.tabs API to open the window.
Related
I'd like to use the popup of an extension to set settings that make changes on about:blank pages html one is on (from Google Slide Presenter in a separate tab), in terms of how the extension is supposed to behave on that page.
As far I understood I need to use content_scripts due to about:blank which requires "match_about_blank" : true as otherwise I have not way to run javascript on that page via the extension, unless there is a way using executeScript?
Is it possible from within the popup to access the HTML of that open tab using content_script?
I.e. I'd like to retrieve the tabs page title, i.e. using document.title or extract from the HTML. Also with Javascript I'd like to change some of the content within a div.
The only workaround I can think of, unless its the only way, is to run javascript on the page to extract and store the value (chrome.storage.sync.set) so I can retrieve it in the popup with javascript (chrome.storage.sync.get).
Wondering if there is a better way directly and also how to change content in the tab i.e. by clicking a button in the popup (maybe via event listener on the tab and a push from the popup?).
I already tried the answer using chrome.scripting.executeScript. with Manifest v3 but couldn't make it work. How to access the webpage DOM/HTML from an extension popup or background script?
When You make a link in a google document it takes two steps to open the link. (First click on the link and then click once again to open it.)
Is it possible to make a script that opens the link right away when you just click on the link in the document?
Here is the link to the sample sheet with a link in it:
https://docs.google.com/document/d/1o0hE6fy2DFRvIddj10H1jECl4ALbs3JxweS8qm63sIc/edit
A script can only allow you to perform actions for which the endpoint is implemented in the UI
Given that the UI of Google Documents is set up in a way that after clicking on a link text you have to click a second time on the actual URL showing up - unfortunately there is no way to modify this default behavior programmatically.
I have index page that contains items i want to keep on all the pages. And i have iframe in the middle of the index page, where all the content is shown.
<iframe id="midfr" src="news.html"></iframe>
When clicking on links, content goes to midfr, while website url is always like www.example.com/
Is there a way to have urls like www.example.com/iframe_url/ when going to specified page using iframes? I dont even have a clue on how to do that.
However ive seen some websites that have some constant divs, while main content blinks on visiting links. Although their source code didnt include any iframes..
No, because iframes don't provide any events to the DOM that you can use to change the URL.
Even if your write it as a method to capture and execute the event. You will still not get it. Because it is not allowed.
Iframe won't provide control over any event, untill the code to handle the event is already a part of it.
You can change the Website's URL using History PushState method. But only if you can have an event to do that. Since iframes don't provide you with an event you won't be able to change the URL.
I would like to share an affiliate link that points to an iOS app in Apple's Appstore. Is it possible to mask it or create a sort of proxy to it, in a way that another user can not access it directly while at the same time maintaining its function as an affiliate link?
Its not possible to completely hide it, but it would be possible to hide the url from non-technical users using a few tricks.
You can put an onclick event handler on the link instead of an href attribute so that the user cannot get the URL by right-clicking the link.
Here's a sample code at jsfiddle.
javascript:q=location.href;p=document.title;void(open('http://example.page/links/bookmarklet_new?
link%5Burl%5D='+encodeURIComponent(q)+'&link%5Btitle%5D='+encodeURIComponent(p),'Page','toolbar=no,width=700,height=350'));
Im using Bookmarklet script like above. But in case if user is not logged he is redirected to root_path. But then I would like to scroll or center page to login form. I tried override styles. But how to check when page is open in popup window?
Have your bookmarklet add a query string parameter like &view=popup, then the page you open can check the query parameter and change the HTML or CSS as necessary. If your page redirects, make sure it checks for the view parameter and passes it to the next page.
Another option for showing the correct part of the page within the window is to use a hash and a fragment identifier in the url. For example #loginform.