Click here to Skip to main content
15,885,875 members
Articles / Mobile Apps / iPhone
Tip/Trick

JavaScript for Bookmark Login

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Oct 2013CPOL3 min read 24.3K   7   4
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)


Written By
Software Developer (Junior) http://www.ipi-international.me.uk
United Kingdom United Kingdom
Developed my 1st Accounts Database in 1994 using Lotus 123. Following that, a Payroll Database in 1999 using Microsoft Access 1997. I then went on to developing my 1st intergrated Multi Currency and Multi Department Accounts and Payroll database in 2002 using Microsoft Access 2000 then upgraded it to 2003.

I have been sharing Microsfot Software Solutions on the web since 1999. In trying to improve the quality of my work, I have studied Microsoft Office packages from 95 to 2013, Microsoft SQL Server version 7 to 2012 Dev, MySQL, PHP, C++, visual Basic 6, HTML, CSS, XML, Vbscript, JavaScript, DOS, IIS version 4 to 7 and all Microsoft Client and Server Operating Systems from Windows 95 to Windows 8 Pro.

My aim is to learn and utilize everything that makes an office run smoothly.

Specialties
Vbscript, SQL Script, JavaScript, Visual Basic Macros, Microsoft Excel and Access Macros, Stored Procedures, C# for Asp.Net, SSRS.

Comments and Discussions

 
GeneralThanks Pin
IPI Paul2-Oct-13 10:12
IPI Paul2-Oct-13 10:12 
GeneralGreat post Pin
pavanbhardwaj872-Oct-13 0:09
pavanbhardwaj872-Oct-13 0:09 
GeneralUsefull Pin
HarryBauer2471-Oct-13 22:45
HarryBauer2471-Oct-13 22:45 
SuggestionDevelopment Pin
IPI Paul5-Apr-13 9:17
IPI Paul5-Apr-13 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.