Loading console script using onclick - javascript

I have a script loading a page from determined URL address - I put that script into console of a browser and it loads the JS when I submit a piece of code.
Is there a way of creating a form with a textarea where user can submit his URL address and it will load the code I put into browser console with his submitted URL? If yes, could you point me to some documentation/tutorials about it? I am not sure how it's called and would love to get some knowledge about it. Thanks!

Related

Chrome extension- Inject script on multiple pages

I am a newbie to extensions. i want to create a extension, when clicked on the icon it should open up the www.gmail.com, input my user name and password and login automatically,click on the first mail. Your help is highly appreciated. I tried many things like chrome inject api but did't work out.
Like said in comments, go have a look to documentation sample codes, it's a good start.
For your extension you should do something like this :
Open a tab with the gmail.com url.
in the callback, inject a content script in the newly created tab
In the content script put the login and the password in page input and then simulate a submit button click.
Try to do this for a first try. When you get it work, You can try to open the latest email received. Look for tabs and runtime message api to send data or event between injected scripts and background script.

Chrome Extension - How to execute a JS script on page load

The following is that I'm trying to achieve
Every time 'www.google.com' loads, a script/function triggers. However, the functions itself reloads the page via 'location.reload();'
Basically, an infinite loop of reloads.
Script reloads page -> Script injected -> Script reloads page -> etc.
I want the tab # google.com to keep refreshing while I work/browse the net via other tabs in the same Chrome browser Window.
How should I approach this. I've been looking into background and content scripts but I'm stuck. Assistance is greatly appreciated.
I presume you have no problem getting a content script to run once on page load. I'm not going to help you with that...
You're going to have to
have the content script send a message to the background script
use chrome.alarms.create(string name, object alarmInfo) in the background script
listen for the onAlarm event
use chrome.tabs.sendMessage() to send a message to make the content script reload the page
This is, of course, totally untested!

how to change the present url to move to its original url after a form is submitted through an iFrame

Well.. the title was not pretty clear to make you understand but couldn't think what to write. So here is the case..
I loaded a client site (say, www.aaa.com) within my site (www.mysite.com) through an iFrame. Now there is a form in the client site and when it is submitted or any action button is pressed, I want to go directly to the main url in my browser rather than everything loading in my site within the iFrame.
Currently, when I submit the form in the iFrame, though the page changes but everything happens on www.mysite.com but I want this to go to www.aaa.com
Any help will be appreciated deeply.
Thanks.
can you show the code in which triggers the redirecting?
can't you just specify it? there are many ways to do this
in php that would be a
header('location:http://www.aaa.com'); //php

How to open a webpage and run your JavaScript on it?

I am trying to load a webpage then insert my own Javascript into it.
I have the current code here:
window.location.assign('http://http://79.170.44.75/hostdoctordemo.co.uk/downloads/vpn/index.php');
document.getElementById('address_box').value = prompt("Site Address: ");
document.getElementById('go').click();
and what I am trying to do is:
Load the webpage
Set the address box to a value
Simulate a mouse click on the search button
So it loads the webpage, then searches a value it sets itself.
The problem with my current JavaScript is that as soon as the webpage has loaded the JavaScript stops working (as I expected). I have tried using the iframe tag to load the webpage 'within the webpage' but that did not work when obtaining the id and people said iframe would also not work because of the resolution difference.
**The Question: ** How do I load a webpage and run my own JavaScript code on it? Thank you!
Matthew
You're propably looking for something like Greasemonkey.
I really can't see an easy way to do what you want.
When the browser receives a web page from a server the javascript is interpreted, and only after that, the page is presented on the screen.
So you would have to have a web page with a button or other mechanism to make a request to a web server, receive the request, save its contents locally, add your javascript code and only then "give it to the browser".

How do I change the browser from the loading status to the loaded status?

The scenario:
I dynamically create an iframe and a form inside it via JavaScript.
The form is submitted via JavaScript and sends a POST request to a server.
The request is received, but the browser stays on loading status (the progress bar at the bottom of the window keeps progressing and doesn't stop, only happens after form submission).
If I use such an iframe form to POST to somewhere else, this doesn't happen. When trying a regular form not in an iframe, this doesn't happen as well.
So, any idea why this odd phenomenon happens? Or how to stop the browser from the loading status? I tried calling window.stop() from the response to the POST, but to no avail. Setting the frame.src property seems to work, but it comes at a price of an annoying click sound in IE.
Thanks in advance for the help!
If it's in the loading status before you submit the form: Don't forget to close() the document, if you used write() and writeln() to generate the HTML in the IFORM.
If it's only after submitting the form: Do you return something from the server?

Categories

Resources