Advertisement
bpoole

Jump to Recipe

Aug 14th, 2020
1,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. as = document.getElementsByTagName('a');
  2. var jump_found = false;
  3. var print_url = '';
  4. for(i = 0; i < as.length; i++){
  5.     if(as[i].innerHTML != '' && as[i].innerHTML.match(/jump/i) && as[i].getAttribute('href')){
  6.         window.location = as[i].getAttribute('href');
  7.         jump_found = true;
  8.         break;
  9.     }
  10.     else if(print_url == '' && as[i].innerHTML != '' && as[i].innerHTML.match(/print/i) && as[i].getAttribute('href')){
  11.         print_url = as[i].getAttribute('href');
  12.     }
  13. }
  14.  
  15. if(!jump_found){
  16.     if(print_url != ''){
  17.         window.location = print_url;
  18.     }
  19.     else{
  20.         alert('sorry, you\'re on your own');
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement