Skip to content

Instantly share code, notes, and snippets.

@xagronaut
Last active July 20, 2018 22:51
Show Gist options
  • Save xagronaut/3fe9afc617c94a126d85c790f1b58b73 to your computer and use it in GitHub Desktop.
Save xagronaut/3fe9afc617c94a126d85c790f1b58b73 to your computer and use it in GitHub Desktop.
Bookmarklets for use in Salesforce development (tested in Google Chrome)
<!DOCTYPE html>
<html>
<head>
<title>Salesforce development tool info - Jeffrey Miller</title>
<style type='text/css'>
body {
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 12;
}
blockquote {
border-radius: 5px;
padding: 15px;
border: 1px solid #999999;
box-shadow: 2px 2px #CCCCCC;
}
.instructions {
border-radius: 5px;
background-color: #FFFFA5;
padding: 15px;
border: 1px solid #999999;
box-shadow: 2px 2px #CCCCCC;
}
div.section, div.entry {
border: 1px solid #999999;
/*border-radius: 5px;*/
margin: 3px;
margin-top: 10px;
padding: 15px;
}
div.section {
background-color: C1C1C1;
}
div.entry {
background-color: #FFFFFF;
}
div.entry blockquote {
background-color: lightgreen;
margin-top: 15px;
}
a[href*="javascript"] {
display: inline-block;
background-color: blue;
color: #ffffff;
padding: 5px;
font-weight: bold;
border-radius: 5px;
border: 3px solid teal;
}
</style>
</head>
<body>
<h1>Salesforce Admin Bookmarklets</h1>
<div class="section">
<p class="instructions"><strong>Drag these links to your browser toolbar</strong>, and click them when logged into Salesforce to extract key details useful for reporting configuration changes.</p>
<div class="entry">
<a href="javascript:(function()%7Bvar%20devTrackedItems%20%3D%20JSON.parse(localStorage.getItem('devTrackedItems'))%20%7C%7C%20%7B%7D%2C%20id%20%3D%20window.location.pathname.substr(1)%2C%20title%3D((document.querySelector('div.bPageTitle%20h1.pageType')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'')%20%2B%20'%3A%20'%20%2B%20((document.querySelector('div.bPageTitle%20h2.pageDescription')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%3BdevTrackedItems%5Bid%5D%20%3D%20title%20%2B%20'%5Cn'%20%2B%5B%5D.slice.call(document.querySelectorAll('div.bDetailBlock%20table.detailList%20tr')%2C%200).filter(function(item%2C%20index)%20%7B%20return%20index%20%3D%3D%200%20%7C%7C%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%3D%3D%20'Name'%3B%20%7D).map(function(item%2C%20index)%20%7B%20return%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%3A%20'%20%2B%20((item.querySelector('td.dataCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%3B%20%7D).join('%5Cn')%20%2B%20'%5Cn'%20%2B%20'ID%3A%20'%20%2B%20id%20%2B%20'%5Cn%5Cn'%20%2B%20window.location.href%20%2B%20'%5Cn%5Cn'%3BlocalStorage.setItem('devTrackedItems'%2C%20JSON.stringify(devTrackedItems))%3Balert(%60Item%20tracked%3A%20%24%7Btitle%7D%60)%7D)()">Track Salesforce Item</a> | <a href="javascript:(function()%7Bvar%20devTrackedItems%20%3D%20JSON.parse(localStorage.getItem('devTrackedItems'))%20%7C%7C%20%7B%7D%2C%20devTrackingLog%20%3D%20Object.keys(devTrackedItems).map(function(item)%20%7B%20return%20(devTrackedItems%5Bitem%5D%20%7C%7C%20'').trim()%3B%20%7D).join('%5Cn%5Cn----%5Cn%5Cn')%2C%20devLogBox%3B(devLogBox%20%3D%20document.querySelector('%23devLogBox')%20%7C%7C%20((devLogBox%20%3D%20document.createElement('textarea'))%2C%20devLogBox.id%20%3D%20'devLogBox'%2C%20devLogBox.setAttribute('rows'%2C%20'5')%2C%20devLogBox.setAttribute('cols'%2C%20'50')%2C%20devLogBox)%20%26%26%20%20document.querySelector('body').appendChild(devLogBox))%3BdevLogBox.innerHTML%20%3D%20devTrackingLog%3B%20devLogBox.select()%3B%20devLogBox.focus()%3Bconsole.log(devTrackingLog)%3Balert('Your%20log%20is%20in%20your%20browser%5C's%20console%20output.%20Check%20there.')%7D)()">Dump Salesforce Log</a> | <a href="javascript:(function()%7B(confirm('Clear%20tracked%20items')%20%26%26%20(localStorage.removeItem('devTrackedItems')%2C%20alert('Items%20cleared')%2C%20true))%20%7C%7C%20alert('Items%20not%20cleared')%7D)()">Clear Salesforce Log</a>
<blockquote>
<p>Use these tools together to track Salesforce items in bulk, then dump the log. You can clear them too.</p>
<p>Note: The logs are isolated by sandbox/domain.</p>
</blockquote>
</div>
<div class="entry"><a href="javascript:(function()%7B%5B%5D.slice.call(document.querySelectorAll('*')%2C%200).filter(function(item)%20%7B%20var%20text%3D((item%20%7C%7C%20%7B%20innerHTML%3A%20''%20%7D).innerHTML%20%7C%7C%20'').trim()%3B%20return%20text.match(%2F%5E%5B0-9A-Za-z%5D%2B%24%2F)%20%26%26%20text.length%20%3D%3D%2015%20%3B%20%7D).map(function(item)%20%7B%20var%20link%20%3D%20document.createElement('a')%3B%20link.setAttribute('target'%2C%20'_blank')%3B%20link.setAttribute('style'%2C%20'margin%3A%203px%3B%20padding%3A%205px%3B%20background-color%3A%20yellow%3B')%3B%20link.setAttribute('href'%2C%20window.location.origin%20%2B%20'%2F'%20%2B%20item.innerHTML.trim())%3B%20link.innerHTML%20%3D%20'Go!'%3B%20item.appendChild(link)%3B%20return%20link%3B%20%7D)%7D)()">Make Jump Links</a>
<blockquote>
<p>This adds hyperlinks for any of those magic Salesforce identifiers that aren't already links. Click the bookmarklet, then click "Go!" next to the ID. Bam!</p>
</blockquote>
</div>
<div class="entry"><a href="javascript:(function()%7Bprompt('Salesforce%20details'%2C%20((document.querySelector('div.bPageTitle%20h1.pageType')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%3A%20'%20%2B%20((document.querySelector('div.bPageTitle%20h2.pageDescription')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%5Cn'%20%2B%5B%5D.slice.call(document.querySelectorAll('div.bDetailBlock%20table.detailList%20tr')%2C%200).filter(function(item%2C%20index)%20%7B%20return%20index%20%3D%3D%200%20%7C%7C%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%3D%3D%20'Name'%3B%20%7D).map(function(item%2C%20index)%20%7B%20return%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%3A%20'%20%2B%20((item.querySelector('td.dataCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%3B%20%7D).join('%5Cn')%20%2B%20'%5Cn'%20%2B%20'ID%3A%20'%20%2B%20window.location.pathname.substr(1)%20%2B%20'%5Cn%5Cn'%20%2B%20window.location.href%20%2B%20'%5Cn%5Cn')%7D)()">Grab Salesforce Details</a>
<blockquote>
<p>You will be given a prompt from the current window. Just copy the contents and paste elsewhere as needed.</p>
</blockquote>
</div>
<div class="entry"><a href="javascript:(function()%7Bprompt('Salesforce%20details'%2C%20('%23%23%20'%20%2B%20(document.querySelector('div.bPageTitle%20h1.pageType')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%3A%20'%20%2B%20((document.querySelector('div.bPageTitle%20h2.pageDescription')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'%5Cn'%20%2B%5B%5D.slice.call(document.querySelectorAll('div.bDetailBlock%20table.detailList%20tr')%2C%200).filter(function(item%2C%20index)%20%7B%20return%20index%20%3D%3D%200%20%7C%7C%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%3D%3D%20'Name'%3B%20%7D).map(function(item%2C%20index)%20%7B%20return%20'**'%20%2B%20((item.querySelector('td.labelCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%20%2B%20'**%3A%20'%20%2B%20((item.querySelector('td.dataCol')%20%7C%7C%20%7B%7D).innerText%20%7C%7C%20'').trim()%3B%20%7D).join('%5Cn')%20%2B%20'%5Cn'%20%2B%20'**ID**%3A%20'%20%2B%20window.location.pathname.substr(1)%20%2B%20'%5Cn%5Cn'%20%2B%20window.location.href%20%2B%20'%5Cn%5Cn')%7D)()">Grab Salesforce Markdown</a>*
<blockquote>
<p>You will be given a prompt from the current window. Just copy the contents and paste elsewhere as needed.</p>
<p>* Note: the formatting of this text will use Markdown syntax. This is great for pasting in README.md files or Git-based repos. You may need an extra tool such as VSCode or MarkdownPad2 to leverage the full features of Markdown, but it's worth it!</p>
</blockquote>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment