Skip to content

Instantly share code, notes, and snippets.

@gofydo
Last active March 27, 2018 20:31
Show Gist options
  • Save gofydo/3a170dd3b3b9fa74b6c60234f5ae59c4 to your computer and use it in GitHub Desktop.
Save gofydo/3a170dd3b3b9fa74b6c60234f5ae59c4 to your computer and use it in GitHub Desktop.
A JS bookmark that prompts for a piece of swappable URL params, and navigates to it in a new tab.
javascript:(function() {
var url = "https://www.google.com/search?safe=active&biw=1302&bih=916&tbm=isch&source=lnt&tbs=isz:ex,iszw:128,iszh:128&q={q}";
var prompt = 'Name the icon:';
var input_text = '';
function isValid() {
return q.length > 0;
}
function getQuery() {
return window.prompt(prompt, input_text);
};
var q = getQuery();
if (q == null){
return;
}
while (!isValid(q)){
var q = getQuery();
}
window.open(url.replace('{q}', q)).focus();
})()
@gofydo
Copy link
Author

gofydo commented Mar 20, 2018

Another example to search for a JIRA ticket.

javascript:(function() {
  var url = "https://goscoutgo.atlassian.net/browse/{q}"; 
  var prompt = 'What Jira Ticket are you looking for?';
  var input_text = 'SCR-';
  function isValid(q){
    return (q.indexOf('-') >= 0 && q.split('-')[1].length > 0);
  }

  function getQuery() {    
    return window.prompt(prompt, input_text);  
  }; 
  var q = getQuery();  
  if (q == null){   
    return;
  }  
  while (!isValid(q)){    
    var q = getQuery();  
  }  
  window.open(url.replace('{q}', q)).focus();
})()

@gofydo
Copy link
Author

gofydo commented Mar 22, 2018

MILTON TPX Jenkins Build Params

javascript:(function() {
  var url = "https://jenkins-ci.goscoutgo.com/job/milton-tpx-ci-github/{q}/parameters/"; 
  var prompt = 'What Milton-TPX build are you looking for?';
  var input_text = '';
  function isValid(q){
    return q !== '';
  }

  function getQuery() {    
    return window.prompt(prompt, input_text);  
  }; 
  var q = getQuery();  
  if (q == null){   
    return;
  }  
  while (!isValid(q)){    
    var q = getQuery();  
  }  
  window.open(url.replace('{q}', q)).focus();
})()

@gofydo
Copy link
Author

gofydo commented Mar 27, 2018

SCOUT-APP Jenkins Build Params

javascript:(function() {
  var url = "https://jenkins-ci.goscoutgo.com/job/scout-app-ci-build-github/{q}/parameters/"; 
  var prompt = 'What SCOUT-APP build are you looking for?';
  var input_text = '';
  function isValid(q){
    return q !== '';
  }

  function getQuery() {    
    return window.prompt(prompt, input_text);  
  }; 
  var q = getQuery();  
  if (q == null){   
    return;
  }  
  while (!isValid(q)){    
    var q = getQuery();  
  }  
  window.open(url.replace('{q}', q)).focus();
})()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment