Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / iPhone

JavaScript for Bookmark Login

0.00/5 (No votes)
1 Oct 2013CPOL3 min read 24.8K  
Use this script to create Bookmarks that enable quick Login to your favourite sites.

Introduction

This code has been designed to list all the Tags on a web page that have an Id and then allow the user to select that element and enter a value that should be inserted into that element's value. A JavaScript is then generated that can be pasted in to a bookmark URL to enable one click entry in to most websites. Starting with a basic single entry code for updating the Username / ID, I have updated the code to allow multiple Input field updating and drilling down two layers of iFrame. Tested on the Pizza Express Voucher entry field, I felt this addition to be of some benefit.

Background

As a lot of my time between contracts is spent job searching, I visit a lot of Job Search web sites. Some of my contracts span over 2 to 3 years and trying to remember all the Login Ids for all the websites can be a bit mind blowing.

In my recent job search activity, I have tried to protect my own software developments by limiting my PC's Internet presence and opting for the use of my iPhone and or iPad, with the occasional need of my Nokia N810 whenever a non image file needs to be uploaded.

Using the Code

I have added another prompt function to give you the chance to search elements by Name where forms are concerned. Also added the function top pre-populate the Enter Value prompt with the value already in the element. The code below can be pasted into a browser bookmark using the following method:

  • Create a bookmark to this page and give it a title like Login Script.
  • Save the bookmark to where you feel it will be quickly accessed.
  • Copy the script below.
  • Edit the bookmark Login Script and delete the URL, then paste in the copied script.
  • Click Done to finish editing and Save the bookmark.
  • Go to the Login page of any website and click the Login Script bookmark (it usually makes it easier to identify the desired input box by entering some text, i.e., 'aa').
  • A prompt box will list all the Elements on that page that have an ID and if you have entered some text, that text will also be shown as the value.
  • Enter the Number displayed for that element in the input field.
  • If the element you select is an iFrame, the code will then generate another list of elements within that iFrame. This code will allow you to go as deep as an iFrame within another iFrame. You should ensure to update all the Elements on the upper layers before drilling down in to any iFrames.
  • A second input box will request the value you wish to assign to that element and you can enter anything such as an Email Address.
  • A third input box will ask you if you wish to update any other elements within the layer you are in. The code allows for anything up to 77 elements.
  • The last input box will give you the script you need. SelectAll and Copy the script given.
  • Finally, create two bookmarks to the Login Page you are on and give the Second Title an ending of ID
  • Edit the ID bookmark and replace the URL with the generated script you copied from the Prompt Box.
JavaScript
javascript:
    var a,b,c,d,e="",f,g="",h,i,j,k,l;
    a=document.getElementsByTagName('*');
    for(f=0;f<77;f++){
        j=prompt("Please choose the element ID type, 1='id', 2='name'!","1");
        getEl();
        if(c>-1){
            if(j==1){
            d=prompt("Please give me the value for "+a[c].id+"!",a[c].value);
            g=g+e+"document.getElementById('"+a[c].id+"').value='"+d+"';";}
        else {
            d=prompt("Please give me the value for "+a[c].name+"!",a[c].value);
            g=g+e+"getElementById('"+a[c].name+"').value='"+d+"';";}
            a[c].value=d;
            if(prompt("Update another Element in this selection?  
            Y=Yes, N=No!","n").toLowerCase()=="n"){
                prompt("Use this script!","javascript:"+g+"Return;");
                f=76;
                Return;
            }
        }
    } 
function fndEl(a){
    for(i=0;i<a.length;i++){ if(j="=1){k=a[i].id;}" 
    {k="a[i].name;}" if(!k||k="=""){}" b="b+i+")" "+k+"="+a[i].value+" c="-1;" 
    if(a[c].tagname="="IFRAME"||a[c].tagName=="FRAME")
    {" j="prompt("Please" 1="id" 2="name" 
    e="document.getElementById('" a="a[c].contentWindow.document.getElementsByTagName('*');" 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)