Skip to content

Instantly share code, notes, and snippets.

@dotspencer
Last active February 12, 2016 18:38
Show Gist options
  • Save dotspencer/7ab383cd1e0ab7dc4c63 to your computer and use it in GitHub Desktop.
Save dotspencer/7ab383cd1e0ab7dc4c63 to your computer and use it in GitHub Desktop.
Jump to Project by I#, Staff Export, Staff Page Standardization

EGI Userscripts

EGI

// ==UserScript==
// @name Jump to project by I#
// @namespace http://spencerlarry.com/
// @version 0.1
// @description enter something useful
// @author You
// @match http*://egi.utah.edu/research/current-projects/
// @include http*://egi.utah.edu/*
// @exclude http*://egi.utah.edu/wp-admin/*
// @grant none
// ==/UserScript==
var new1 = document.createElement('div');
new1.innerHTML = '\
<div id="larry">\
<input id="jump-box" type="text" placeholder="I Number"><div></div>\
<style>\
#larry{margin:5px;width: 235px;}\
#jump-box{cursor:text;}\
#jump-box:focus{outline:deepskyblue 2px solid !important;}\
</style>\
';
document.getElementsByClassName('container')[0].appendChild (new1);
var jumpBox = document.getElementById('jump-box');
jumpBox.addEventListener('keypress', function (e) {
var key = e.which || e.keyCode;
if (key === 13) { // 13 is enter
var inputValue = jumpBox.value;
inputValue = inputValue.replace(/\s+/g, '');
inputValue = inputValue.toLowerCase();
window.location = "http://egi.utah.edu/research/current-projects/" + inputValue + "/";
}
});
// ==UserScript==
// @name Salesforce Contact Helper
// @namespace https://spencerlarry.com
// @version 0.3
// @description try to take over the world!
// @author Spencer Smith
// @match https://na16.salesforce.com/003/e?retURL=%2Fhome%2Fhome.jsp
// @match https://na16.salesforce.com/003/e*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
// Just a random element to add my html to.
var pb = document.getElementsByClassName('pbSubsection')[document.getElementsByClassName('pbSubsection').length -1];
pb.innerHTML +=
"<div id='panel'>"+
"<div style='display: none;'><input type='text' id='PreventChromeAutocomplete' name='PreventChromeAutocomplete' autocomplete='address-level4'/></div>"+
"<ul>"+
"<li><input id='first' placeholder='First Name'/></li>"+
"<li><input id='last' placeholder='Last Name'/></li>"+
"<li><input id='title' placeholder='Title'/></li>"+
"<li><input id='phone' placeholder='Phone'/></li>"+
"<li><input id='email' placeholder='Email'/></li>"+
"<li><div id='account' class='butt'>Select Account</div><div id='save' class='butt'>Save &amp; New</div></li>"+
"</ul>"+
"</div>";
pb.innerHTML +=
"<style>"+
"#panel{background-color:#E0E3E5;display:inline-block;position:fixed;right:0px;top:250px;box-shadow: 0 0 4px -1px;padding:10px;}"+
"#panel input{padding:5px;margin:10px;font-size:18px;font-family:'Helvetica';}"+
"#panel input:focus{outline:3px #36a0fe solid;}"+
"#panel ul{list-style-type:none;margin:0;padding:0;}"+
"#panel li{margin:0;}"+
".butt{padding:8px;background-color:gray;float:left;color:white;margin:10px;cursor:pointer;transition:.1s;}"+
".butt:hover{background-color:#999;}"+
"#save{background-color: #4CAF50;display:none;}"+
"#save:hover{background-color:#5ACC5E;}"+
"</style>";
var panel = document.getElementById('panel');
var first = document.getElementById('first');
var last = document.getElementById('last');
var title = document.getElementById('title');
var phone = document.getElementById('phone');
var email = document.getElementById('email');
var account = document.getElementById('account');
// Salesforce document elements
var sFirst = document.getElementById('name_firstcon2');
var sLast = document.getElementById('name_lastcon2');
var sTitle = document.getElementById('con5');
var sPhone = document.getElementById('con10');
var sEmail = document.getElementById('con15');
// For page refresh to copy back info after selecting company account
first.value = sFirst.value;
last.value = sLast.value;
title.value = sTitle.value;
phone.value = sPhone.value;
email.value = sEmail.value;
window.setTimeout(function(){
first.focus();
// Hides the save button if company is not selected after page refresh
var emptyAccount = document.getElementsByClassName('emptyDependentLookup')[0].style.display;
if(emptyAccount == "none"){
save.style.display = "block";
}
}, 1000);
panel.addEventListener("keydown", type);
panel.addEventListener("keyup", type);
account.addEventListener("click", function(){document.getElementById('con4_lkwgt').click()});
save.addEventListener("click", function(){document.getElementById('bottomButtonRow').children[1].click()});
function type(){
sFirst.value = first.value;
sLast.value = last.value;
sTitle.value = title.value;
sPhone.value = phone.value;
sEmail.value = email.value;
}
// ==UserScript==
// @name Staff List Export to Console
// @namespace http://spencerlarry.com
// @version 0.1
// @description enter something useful
// @author Spencer Smith
// @match http://egi.utah.edu/about/staff/
// @include https://egi.utah.edu/about/staff/
// @grant none
// ==/UserScript==
window.onload = function(){
var list = "";
var names = document.getElementsByTagName('h3');
//Splits string into array at <br>. Takes first array [0] before <br>.
for (i = 0; i < names.length; i++) {
list += names[i].innerHTML.split('<br>')[0] + '\n';
}
console.log(list);
}
/* This was my way. Finds index of <br> then takes the substring from index 0 to <br> and adds a space.
for(i=0;i<names.length;i++){
list += names[i].innerHTML.substring(0, names[i].innerHTML.indexOf('<br>')) + " ";
}*/
/* Another creative solution from stackoverflow
for(i=0;i<names.length;i++){
list = list.concat(names[i].firstChild.nodeValue + '\n');
}*/
// ==UserScript==
// @name Standardization Tool
// @namespace http://spencerlarry.com/
// @version 0.1
// @description Checks if main image is set to the standard for all staff photos
// @author Spencer Smith
// @match http://egi.utah.edu/about/staff/spencer-smith/
// @include http*://egi.utah.edu/about/staff/*
// @include http://egi.utah.edu/about/affiliate-scientists/*
// @exclude http://egi.utah.edu/about/staff/
// @exclude http://egi.utah.edu/about/affiliate-scientists/
// @exclude http://egi.utah.edu/about/staff/update-staff-information/
// @grant none
// ==/UserScript==
var new1 = document.createElement('div');
new1.innerHTML = '\
<div id="tools">\
<div id="ind1" class="gray ind"></div><p>Image - 216x270</p>\
<div id="ind2" class="gray ind"></div><p>Title</p>\
<div id="ind3" class="gray ind"></div><p>1st Tab</p>\
<div id="ind4" class="gray ind"></div><p>2nd Tab</p>\
</div>\
\
<style>\
*{margin:0px;}\
#tools{\
position: absolute;\
top: 25px;\
right: 200px;\
width: 155px;\
background-color: white;\
border-width: 1px;\
border-style: solid;\
border-color: lightgrey;\
padding:5px;\
padding-bottom:0px;\
}\
p{\
margin-left:10px;\
color:black;\
}\
.ind{\
width: 24px;\
height: 24px;\
display: inline-block;\
margin-right: 5px;\
float: left;\
}p{margin-bottom:5px;}\
.gray{\
background-color: lightgrey;\
opacity:.5;\
}\
.green{\
background-color: limegreen;\
opacity:1;\
}\
.red{\
background-color: red;\
}\
.blue{\
background-color: deepskyblue;\
}\
</style>\
';
document.getElementsByClassName('main-row')[0].appendChild (new1);
var photo = document.getElementsByClassName('vc_box_border vc_box_border_grey')[0];
var wrapper = document.getElementsByClassName('wpb_wrapper');
var ind1 = document.getElementById('ind1');
var ind2 = document.getElementById('ind2');
var ind3 = document.getElementById('ind3');
var ind4 = document.getElementById('ind4');
//Photo checker
if (photo.naturalHeight == 270){
ind1.className = ind1.className + " green";
photo.style.background = "limegreen";
}else{
//ind1.className = ind1.className + " red";
//photo.style.background = "red";
//alert("Image dimensions: " + photo.naturalWidth + " x " + photo.naturalHeight);
}
/*
//Title Checker
if (wrapper[3].children[1].tagName == "H2"){
ind2.className = ind2.className + " green";
}
//Tab 1 Checker
if (wrapper[6].children[1].tagName == "H3"){
ind3.className = ind3.className + " green";
}
//Tab 2 Checker
if (wrapper[7].children[1].tagName == "H3"){
ind4.className = ind4.className + " green";
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment