JavaScript - Bookmarklet Help For Auto-following A Link
I'm trying to write a bookmarklet to automatically follow a specific link on a page without manually clicking or selecting the link. It's for the Facebook game Hatchlings. Each time I view someone's page to collect an egg, it has the following text:
You found an egg! Add it to your basket. "Add it to your basket." is the clickable link, but has a different URL embedded in it each time I visit the page. Is there a way to create a bookmarklet to strip out the embedded URL and go to the link without actually clicking on "Add it to your basket." ? Thanks in advance for the help. Similar Tutorialshi everyone i need a script which click on random links on my webpage after page load?i have javascript code which open only link which i write in script but i want the code which click on any available link on my webpage the links change after every 10-15 seconds so i cant set a spacefic link in code please help?
I really don't know what I am doing, but I need to know how to alter this script to load this website without having to click "Weathersentry online". I would like to double click on the icon the code is attached to and it sign in automatically. Can anyone help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Sample Signin link WeatherSentry Online</title> </head> <body> <form id="DTNSigninForm" action="http://weather.dtn.com/dtnweather/common/signin.do" style="margin: 0,0,0,0;" > <a onclick='document.getElementById("DTNSigninForm").submit();return false;' href="javascript:void(0);">WeatherSentry Online</a> <input type="hidden" name="username" value="username" /> <input type="hidden" name="password" value="password" /> <input type="hidden" name="autoLogin" value="true" /> </form> </body> </html> Hi there, I hope this is the right Forum for asking this. I'm trying to build a Bookmarklet for our Institute, which should work with our library repository. The idea is to consult a SQL search within the repository using the serial number of an article or book which is imported into the bookmarklet via getSelection. Then, after the search query is completed, the repository homepage prompts to the results page. This is where I get stuck. The bookmarklet should now simply show a prompt window saying: do you see a found result on this page? Yes or No. If the user clicks nno, the bookmarklet should forward to the import page, if Yes, the entry is already in the repository and the import is unneccessary. javascript:Qr=document.getSelection();if(!Qr)%7Bvoid(Qr=prompt('Please%20type%20repository&20Nr.:',' '))%7D;if(Qr)location.href='http://dali.biologie.uni-ulm.de/refbase-0.9.5/search.php?formType=sqlSearch&submit=&citeStyle=&citeOrder=&sqlQuery=SELECT+author%2C+title%2C+year% 2C+publication%2C+volume%2C+pages+FROM+refs+WHERE+doi+RLIKE+%22'+escape(Qr)+'%22+OR+notes+RLIKE+%22' +escape(Qr)+'%22+ORDER+BY+year+DESC%2C+author&showLinks=1&showRows=30&viewType=Web'; if(confirm('Is%20the%20article%20already%20in%20the%20repository?')) location.href='http://dali.biologie.uni-ulm.de/refbase-0.9.5/import_modify.php?formType=importID&submit=Import&showSource=1&sourceIDs='+escape(Qr) I hope this is not too confusing. Thanks to anyone for help, and have great holidays! Can someone tell me what I am doing wrong here... This returns "Button Not Found" Code: javascript:var nam="http://apps.facebook.com/onthefarm/giftaccept.php?senderId=547766125&gift=haitibackpack_item_single&timestamp=1285776944&ref=gift_accept_tab&key=6870697de39960508737349c7a3f1363%24%24ggM3T%2CPU2YKM2l0mNrM%28U%28b%21eHAoclFCBgwg49%21S34GWkEXxTekFN_Fkx5%2AUZPcNMEOj&signature=a86a9e11aab0051e3fde676a9abe4283&srcapp=FarmVille"; nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click(); This prompts me to enter a URL...I enter the EXACT same URL as in the above example and it works fine, clicks the button which brings me to the desired page. Code: javascript:var nam=prompt('enter URL Please'); nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click(); Thanks Edit: Before you ask...I've tried in Chrome, IE and Firefox. It does not appear to be an issue with the length of the JS. I get the same results as above regardless of which (valid) URL I use. Hi, I am trying to build a bookmarklet to use on the swiss legislation website. All the pages are available in several languages and I want to be able to switch with one button from french to german and from german to french. As an example, the URLs are as follow for the same page: in French: http://www.admin.ch/ch/f/rs/311_0/index2.html in German: http://www.admin.ch/ch/d/sr/311_0/index2.html So I built quite easily two bookmarklets to switch FR-DE and DE-FR: Code: javascript: var str = window.location.pathname;str = str.replace("f/rs", "d/sr");window.location = str; Code: javascript: var str = window.location.pathname;str = str.replace("d/sr", "f/rs");window.location = str; But when I try to get a single script by using if/else, I cannot manage to have the "else" part working: Code: javascript: var str = window.location.pathname; if (location.pathname.indexOf("d/rs") < 0) { str = str.replace("f/rs", "d/sr"); window.location = str; } else { str = str.replace("d/sr", "f/rs"); window.location = str; } Thinking it might have to do with str.replace, I tried an easier variant, but even this one does not work, the "else" part is never called: Code: javascript: var str = window.location.pathname; if (location.pathname.indexOf("d/rs") < 0) { str = str.replace("f/rs", "d/sr"); window.location = str; } else { alert('no'); }; I would appreciate any help on the matter... thanks in advance, RJ Hi, I'm trying to make a JavaScript where when it's clicked, two alert input boxes appear and the user inputs two Facebook users' ID numbers. The script should then load an iFrame with: ttp://www.facebook.com/"+s+"?and="+s2+" Where "s" and "s2" are the variables. Why is the following not working? Code: if (typeof jQuery == 'undefined') { var jQ = document.createElement('script'); jQ.type = 'text/javascript'; jQ.onload=runthis, runthis2; jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; document.body.appendChild(jQ); } else { runthis(), runthis2(); } function runthis() { if ($("#wikiframe").length == 0) { var s = ""; s = getSelText(); if (s == "") { var s = prompt("Person 1"); } if ((s != "") && (s != null)) { $("body").append("\ function runthis2() { if ($("#wikiframe").length == 0) { var s2 = ""; if (s2 == "") { var s2 = prompt("Person 2'"); } if ((s2 != "") && (s2 != null)) { $("body").append("\ <div id='wikiframe'>\ <div id='wikiframe_veil' style=''>\ <p>Loading...</p>\ </div>\ <iframe src='http://www.facebook.com/"+s+"?and="+s2+"' onload=\"$('#wikiframe iframe').slideDown(500);\">Enable iFrames.</iframe>\ <style type='text/css'>\ #wikiframe_veil { display: none; position: fixed; width: 100%; height: 100%; top: 0; left: 0; background-color: rgba(255,255,255,.25); cursor: pointer; z-index: 900; }\ #wikiframe_veil p { color: black; font: normal normal bold 20px/20px Helvetica, sans-serif; position: absolute; top: 50%; left: 50%; width: 10em; margin: -10px auto 0 -5em; text-align: center; }\ #wikiframe iframe { display: none; position: fixed; top: 10%; left: 10%; width: 80%; height: 80%; z-index: 999; border: 10px solid rgba(0,0,0,.5); margin: -5px 0 0 -5px; }\ </style>\ </div>"); $("#wikiframe_veil").fadeIn(750); } } else { $("#wikiframe_veil").fadeOut(750); $("#wikiframe iframe").slideUp(500); setTimeout("$('#wikiframe').remove()", 750); } $("#wikiframe_veil").click(function(event){ $("#wikiframe_veil").fadeOut(750); $("#wikiframe iframe").slideUp(500); setTimeout("$('#wikiframe').remove()", 750); }); } function getSelText() { var s = ''; if (window.getSelection) { s = window.getSelection(); } else if (document.getSelection) { s = document.getSelection(); } else if (document.selection) { s = document.selection.createRange().text; } return s; } Simple enough, one would think, but I'm rusty and haven't done this kind of thing in years. All I need to do is take the current page's url and replace/add a bit into the URL at the appropriate place. For Example, if this is the Current Page URL: Code: http://www.mysite.com/section/main.php?p=1 I want to be able to use the bookmarklet to change it to: Code: http://www.mysite.com/section2/main.php?p=1 This is all I've got for it so far. Probably botched that up too. Code: javascript:(function(){var%20a=document.URL.split("/section/");var%20newURL="www.mysite.com/section2/"+a;}) Hello all i need to be able to make small peace of js code that the user can drag to is IE browser and then invoke it on the page . Hi, I want to open a new window and then execute some js function on that window. My code looks like this: Code: windowObjectReference = window.open("http://some_page.html","name"); windowObjectReference = window.open("javascript:(some_function('param1');)","name"); Is it possible to do activate bookmarklet thru js on new window? Hey all - I need a java bookmarklet that does a real simple thing. I need to take the current URL (ie, where the user is when they click the bookmarklet) and append it to a static URL and return the text on the resulting page. For example: The user is at http://google.com The user clicks the bookmarklet. the bookmarklet takes http://google.com and appends it to http://example.com/outside_create.ph...ey=555&url=URL HERE where you see the URL HERE text. That PHP script echos a simple line of text (a shortened URL actually). Then I want that result from the outside_create.php file to be displayed in a window back to the user. Is this even possible? Basically I need to know how to append location.href to a static URL and how to get the resulting content from the static URL.. hi guys, How could I make this useful dictionary bookmarklet open in a new window? javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.g etSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange( ).text));var%20e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}; Its the "To English" bookmarklet as featured on lifehacker. Thanks! I'm not very well versed in javascript. I'm trying to make a bookmarklet that when I click it will either append text to what I've already written or insert the predefined text at the cursor's position in a textarea. Also the browser I'm trying to do this on is Chromium. Here's what I have: Code: javascript:void((function(){document.getElementsByTagName('textarea')[0].value='ಠ_ಠ'})()) ...but this of course changes the entire value of the text field to: ಠ_ಠ ...rather than appending or inserting at the cursor position. I'm guessing append would be the simplest, though cursor position would be most efficient. So if you can help in anyway, please do! Thanks. Hi, It would be easier to explain this if you play mafia wars (or any game that includes intra-game exchange of gifts/items between members) but the actual scripting doesn't require any knowledge of the game. Background Information Mafia Wars is a game on Facebook (and myspace, yahoo etc.) that among other things allows its players to send gifts to each other. Now because different people end up with more things of one type and are short of things of another type, the players have evolved a trading dynamic. Where x number of Item 1 is traded for y number of Item 2. A simple marketplace. And with this territory come scammers. Essentially a player who doesn't go through with his end of the deal. good player sends item to bad player. bad player removes good player from mafia and blocks him for ever contacting him through his facebook profile. This has given rise to my group, among many others, that lists these scammers (identified with their facebook profile ids) as they are reported every day. Now over time the list has grown and it has become difficult and unrealistic to expect people to know who is on the list and who is not. The Requirement A javascript bookmarklet (there are many already servicing different needs of the players) that sits on the browser and tells the user if the person he is about to trade with is a listed scammer or not. The Breakdown The user will click the bookmarklet when he is on the facebook profile of the person he is about to trade with. When clicked the script will pull the facebook profile id from the current page, and then scan a text file located on a third-party server and return with a pop-up box message that reports if the id is listed as a scammer or not. It should be pretty simple to do, except I don't know the first thing about javascript coding. So if there's anyone who can devote a few hours/days to help us out with this it would be greatly appreciated. Thank you Hi, It would be easier to explain this if you play mafia wars (or any game that includes intra-game exchange of gifts/items between members) but the actual scripting doesn't require any knowledge of the game. Background Information Mafia Wars is a game on Facebook (and myspace, yahoo etc.) that among other things allows its players to send gifts to each other. Now because different people end up with more things of one type and are short of things of another type, the players have evolved a trading dynamic. Where x number of Item 1 is traded for y number of Item 2. A simple marketplace. And with this territory come scammers. Essentially a player who doesn't go through with his end of the deal. good player sends item to bad player. bad player removes good player from mafia and blocks him for ever contacting him through his facebook profile. This has given rise to my group, among many others, that lists these scammers (identified with their facebook profile ids) as they are reported every day. Now over time the list has grown and it has become difficult and unrealistic to expect people to know who is on the list and who is not. The Requirement A javascript bookmarklet (there are many already servicing different needs of the players) that sits on the browser and tells the user if the person he is about to trade with is a listed scammer or not. The Breakdown The user will click the bookmarklet when he is on the facebook profile of the person he is about to trade with. When clicked the script will pull the facebook profile id from the current page, and then scan a text file located on a third-party server and return with a pop-up box message that reports if the id is listed as a scammer or not. It should be pretty simple to do, except I don't know the first thing about javascript coding. So if there's anyone who can devote a few hours/days to help us out with this it would be greatly appreciated. Thank you. Hello, I don't know if this can be done in Javascript, or requires any other language but i was wondering if this would be possible. I would like to embed this Javascript code in to a PHP file and then for it to run automatically upon the PHP file loading: Code: <td class="smallDesc"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </td> The Javascirpt is the Facebook Share button that basically allows users that have Facebook to share the page there currently on in their Facebook status by pressing the button, but if there not logged in it shows the login page, not a problem just continue the script. The current button i which is what i want to load automatically in the PHP file is located here, to test the functionalilty just click "Share" button in blue.. http://watch-movies-online.anyfilman...-Movie-17.html To summarise, i would like the above Javascript code to execute automatically upon pageload of this PHP file.. http://www.watch-movies-online.anyfi...p://google.com. If that could be done, and if this also is possible.. i would like for the "Share" button on the external page that is loaded from the Javascript code above to be clicked automatically so in effect when ever someone visits the PHP page after clicking "Click Here to Watch/Stream 2012 Online For Free" on this page it will automatically load the Facebook Share box, and automatically click the "Share" Button and then close the page if possible, but not required. Please feel free to ask any questions, i'll be happy to answer. Thanks in advance. Best Regards, Jonathan. I'm working on a technical document that has a glossary section. When I use a technical term, I link to its definition in the glossary then provide a return link to return the user to whence they came. But if I use that same term again, and if I want to link it to the glossary, I need to duplicate the glossary entry in order to provide a return link that returns them to the right place. Is there some way I could link them to the glossary and embed a unique return link in the link to the glossary?
Hi everyone - would anyone be able to assist with a code for updating information on a daily basis? For example, I wish to update a section of our site every day that has the following timing information: Everything is tabulated in excel and/or csv, and it also has on line pages in monthly format, but on the main index page, I just need to have a small area that provides it on a daily basis without having to go to an individual monthly page. Dawn Sunrise Mid Day Sunset Hope this make sense! In the same regard, a code that has QUOTES can also be included with daily (automatic) changes. Any help would be greatly appreciated! Thank you! I need to set something up so every X amount of second on a page it goes a certain command, and keeps resetting the counter after everytime and goes again. I thought of many of the timer commands I have found on Google but didn't know if this was the RIGHT way to do it since I want it to be a document command that repeats. If what is returned to the command is true instead of false it needs to be able to change location of the browser, so I didn't know if the timer commands I found were right or not. Thanks. |