Simple chrome redirect extension - javascript

I intend to create a simple chrome extension (for personal use) that simply detects when the user opens a new tab and redirects him to a certain website. The redirection url can be set in the source code, there is no need for some kind of form to submit it (since this will be, like I said, mostly just used by me and I can change that value easily in the code).
The problem is I don't know where to start from or how to start. Can anyone point me in the right direction? I've read google's "Getting started: Building a chrome extension" by the way.
Thanks a lot!

I wrote an extension sometime ago and published it to the chrome webstore https://chrome.google.com/webstore/detail/instructables-default-all/oeeoefddkogaamghjjoelcgmellpacid?hl=en the source code is available here http://code.nishantarora.in/instructables-default-all-steps-chrome-extension/src
The purpose of this extension is to redirect a user opening an instructable on instructables.com should be shown the url appended with ?ALLSTEPS to load the all steps page for that particular instructable. The code is pretty easy to understand.

Related

Chrome extension development - How do I pass info/variables/data from the content.js to the extension?

I'm trying to achieve something very simple and I'm blocked by the not so clear explanations in the chrome extension development official website.
I am trying to build a chrome extension with one button that extract the H2 from the specific page it's on, and pass this data into the extension to be shown there in a list (or something else if more easily implemented).
So from what I read I struggle with the logics of all the files and permissions:
So using the message passing I was able to send this data in a way but it's only working when I reload the page when the extension is opened(clicked on), the moment I close the extension it doesn't work anymore.
I saw that there is a way to use scripts injection with chrome.scripting, have no idea how it works though because when I tried the official documentation example it doesn't have the mechanism of listening to when I click the button in the extension, it just fires away.
There is the local storage, tried it but I had hard time accessing the data it collects with clicking the button inside the extension. if it's possible at all.
I saw couple of guys on youtube talking about passing a message through the background.js, which I can get the data from the content.js but how do I pass it to the extension when I click the button inside of it?
I saw one guy on youtube using var to share the info through the "window." but I know that this might have other problems because the use of a var.
The real question is:
Is there a difference between all those ways? are there any limitations? cons/pros? are there other ways?
Where can I really learn about chrome extension development?
Thanks in advance.

How can i code Zapier to follow a link that was provided in an email?

I am using Mailparser to scrape a booking email, then use Zapier to create a booking in our system.
In the email is a link to confirm the booking so am wanting to use the code action to click on the link or follow the link.
Nothing needs to be seen, just follow the link & allow the page to load. This confirms the reservation
I have attempted using python & JS to no avail.
Can you point me in the right direction?
Thanks for reading!
David here, from the Zapier Platform team.
When you click on a link and it opens in your browser, all that really is is a GET request. If the site you're trying to load is simple, then this can be accomplished with a Webhook by Zapier step that make the request to the provided URL.
The big issue that'll pop up is if the site is more complex. A browser loads and execute all the javascript on the page, which our GET request won't do. If the site uses javascript to confirm the reservation (not just the page loading itself), then this isn't going to work. If that's the case, it's a lot more involved. You'd probably need to make a CLI app and use a tool like PhantomJS that can load pages and everything in them. Note that I haven't tested that on the CLI and there's a chance it's incompatible with the way we run apps, so do a proof of concept before you really dive in.
Hope this helps. ​Let me know if you've got any other questions!

How to convert a link that has javascript:__doPostBack in href to normal url which wget/curl/lynx can understand?

I searched in SO first, and found this question. How to click a link that has javascript:__doPostBack in href? but it gives the answer in python only.
What I need is, when go through a website, some pages (2,3,4, etc) with links like below:
javascript:__doPostBack('AspNetPager1','2')
javascript:__doPostBack('AspNetPager1','3')
javascript:__doPostBack('AspNetPager1','4')
If I click it, and it will display the next page, but the real url isn't displayed in browser.
So my questions is, how can I convert the javascript link into traceable real url and feed to wget/curl/lynx?
My purpose is to use the tools (wget/curl/lynx) to download these pages one by one by scripting. But because of these javascript:__doPostBack, I can't find a good way to do it.
You can't really do it analytically. __doPostBack could be arbitrarily complex.
What you should do instead is install Firebug (assuming you are using Firefox), activate the Network tab, press "Persist", and then click that button. The Network tab will show you the actual network traffic, and you can deduce the real URLs from that. In fact, you can just right-click on the particular network request that interests you and select "Copy as cURL" and it will put the curl instructions -- complete with things like cookies and headers -- in your paste buffer.
There is a similar function built-in to Chrome.

HTML Redirects to wrong

I am doing work for a client and I am beating my head against the wall trying to figure out what is happening on this site. First, he uses godaddy as his host and uses their express email marketing. One of the campaigns he was sending out had a wrong url in it. So that was easy enough to fix once I got logged in. Now, on the email that is sent out there is a link that says "To view this message as a printable PDF document, Click here." and it opens it up in the browser. NOW, I've tried finding the file it opens to change it with no luck. I've tried changing the html file in the directory it points to, but that does nothing and doesn't update the page. Any test page I create and try and open in a browser keeps the url but pulls in a different page (one in particular).
SO, as I've mentioned, in the email version of this, I've gotten it to work, just not in the browser version because I have no idea where it's pulling from or what is overwriting it.
Here is the link
http://nationalproduct.com/emailcampaigns/racing_stepmats/
At the bottom of this page there is a "Printable Version" button. This button should point to here:
/racing_stepmats/pdf/stepmats_racing.pdf#zoom=70
But instead points to here:
/regular_stepmats/pdf/stepmats_regular.pdf#zoom=70
I've also looked at the .htaccess file and there's only one line on there rewrite engine on so there's nothing in the .htaccess that's automatically loading or redirecting that I can see. Any wrong url that a user puts in doesn't go to a page not found, it just keeps what's been typed in the url bar but loads the racing rv mat page. ?:O
I've tried changing it in chrome and firefox in the developer tools and I know how to change the link to be correct, but I have no way of saving it from google or firefox to overwrite, that I know of at least. Any help on this would be greatly appreciated! Thanks in advance!
you just have to edit this part of the source of the page
<area shape="rect"
_mce_shape="rect"
coords="281,787,406,837"
_mce_coords="281,787,406,837"
href="http://nationalproduct.com/emailcampaigns/regular_stepmats/pdf/stepmats_regular.pdf#zoom=70"
_mce_href="http://nationalproduct.com/emailcampaigns/regular_stepmats/pdf/stepmats_regular.pdf#zoom=70">
replacing the wrong URL with the correct one
The owner has 15 different domains and was hosting this site, and all of it's content, in a subfolder. It was on the backend of godaddy where I found all the domains and where they were being hosted. Normally this would have been easier to find but there were hundreds of files and folders on the backend. Thanks for the pointers though ;) Fixed

How to get the actual hard link URLs

I am doing research on a subject. The sites which are developed in javascript for eg. https://hp.taleo.net/careersection/2/jobsearch.ftl# . If we click on the paging, the URL doesn't change and yet the contents of the page are changed. Whether there are some variables which are getting submitted and if yes then what are these variables. What would one have to do if one wants the actual hard link the next page for this site or the similar sites. Thanks in advance.
There are no hard URLs... The site is loading it dynamically through ajax.
Inspect the website using Firefox or Chrome/Safari Dev Tools. Open the network tab and submit the form.
Network Tab
As you can see, it's posting the data to that page. Do some investigation and see what you come up with.
You can also try turning off javascript and seeing if it falls back to hard urls.

Categories

Resources