Commit 19d2b119 by Roman Shevchuk

Init

parents
# Created by .ignore support plugin (hsz.mobi)
.idea/
\ No newline at end of file
html.salesforceuiimprover-enabledScript-showLineNumbersInTables #bodyCell table.list > * > tr > th:first-child::before,
html.salesforceuiimprover-enabledScript-showLineNumbersInTables #bodyCell table.list > * > tr > td:first-child::before {
content: attr(line-number);
display: inline-block;
width: 2em;
color: #aaa;
text-align: right;
padding-right: 10px;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Salesforce UI Improver</title>
<style>
body {
width: 250px;
background: url('../images/logo.png') calc(100% + 47vh) 0 no-repeat;
background-size: contain;
margin: 0;
padding: 8px 20px 8px 8px;
color: #333;
}
.header {
margin: 0 0 5px 0;
}
.footer {
margin: 5px 0 0 0;
}
label {
vertical-align: top;
}
label:hover {
text-decoration: underline;
cursor: pointer;
}
#status {
color: green;
}
a {
color:#015ba7;
}
</style>
<script src="../js/jquery-2.2.4.min.js"></script>
<script src="../js/popup.js"></script>
</head>
<body>
<h3 class="header">Salesforce UI Improver</h3>
<div>
<label><input type="checkbox" name="show1000PerPage"> Show 1000 records per page</label>
</div>
<div>
<label><input type="checkbox" name="showLineNumbersInTables"> Show line numbers in tables</label>
</div>
<div id="status"></div>
<div class="footer">
<a href="http://salesforceuiimprover.com" target="_blank">salesforceuiimprover.com</a>
</div>
</body>
</html>
\ No newline at end of file
"use strict";
$(function() {
restore_options();
$('input').on('change', function(){
save_options();
});
});
// Saves options to chrome.storage
function save_options() {
var show1000PerPage = ($('input[name="show1000PerPage"]:checked').length > 0) ? true : false;
var showLineNumbersInTables = ($('input[name="showLineNumbersInTables"]:checked').length > 0) ? true : false;
chrome.storage.sync.set({
show1000PerPage: show1000PerPage,
showLineNumbersInTables: showLineNumbersInTables
}, function() {
optionsSaved();
});
}
// Restores options using the preferences
function restore_options() {
chrome.storage.sync.get({
show1000PerPage: true,
showLineNumbersInTables: true
}, function(items) {
$('input[name="show1000PerPage"]').attr('checked', items.show1000PerPage);
$('input[name="showLineNumbersInTables"]').attr('checked', items.showLineNumbersInTables);
});
}
function optionsSaved() {
// Update status to let user know options were saved.
var $status = $('#status');
$status.text(' ').stop().slideUp(0);
$status.text('Please, refresh page to see changes').slideDown(100);
setTimeout(function() {
$status.stop().slideUp(100);
}, 1500);
}
\ No newline at end of file
"use strict";
(function(){
console.log('Salesforce UI Improver running');
load_options();
function exec_scripts(options) {
if (undefined !== salesforceuiimprover_scripts) {
if (true === options.show1000PerPage) {
document.documentElement.classList.add('salesforceuiimprover-enabledScript-' + 'show1000PerPage');
salesforceuiimprover_scripts.show1000PerPage();
}
if (true === options.showLineNumbersInTables) {
document.documentElement.classList.add('salesforceuiimprover-enabledScript-' + 'showLineNumbersInTables');
salesforceuiimprover_scripts.showLineNumbersInTables();
}
}
}
function load_options() {
chrome.storage.sync.get({
show1000PerPage: true,
showLineNumbersInTables: true
}, function(items) {
var options = $.extend(options, items);
exec_scripts(options);
});
}
})();
"use strict";
var salesforceuiimprover_scripts = {
show1000PerPage: function () {
var utils = {
getLsrFromUrl: function (url) {
var matches = url.match(/(%3A|[&?])lsr=([0-9]*)/);
if (matches) {
return +matches[2];
}
},
getRowsperpageFromUrl: function (url) {
var rowsperpage_matches = url.match(/((%3A|[&?])rowsperpage)=([0-9]*)/);
if (rowsperpage_matches) {
return +rowsperpage_matches[3];
}
}
};
var nextOrPrevPage = $('.bNext > .withFilter > .next, .listElementBottomNav > .bNext > .next');
nextOrPrevPage.each(function () {
var $this = $(this);
var $prev_link = $this.children('a:eq(0)');
var $next_link = $this.children('a:eq(1)');
if ('Next Page>' === $prev_link.text()) {
$prev_link = $this.children('empty');
$next_link = $this.children('a:eq(0)');
}
console.log($prev_link.text());
console.log($next_link.text());
if ($prev_link.length > 0 || $next_link.length > 0) {
var prev_lsr = undefined;
var next_lsr = undefined;
var url;
if ($prev_link.length) {
url = $prev_link.attr('href');
prev_lsr = utils.getLsrFromUrl(url);
}
if ($next_link.length) {
url = $next_link.attr('href');
next_lsr = utils.getLsrFromUrl(url);
}
var current_rowsperpage = utils.getRowsperpageFromUrl(url);
console.log('Counters:');
console.log('current_rowsperpage : ' + current_rowsperpage);
console.log('prev_lsr : ' + prev_lsr);
console.log('next_lsr : ' + next_lsr);
if (undefined !== prev_lsr || undefined !== next_lsr) {
var current_lsr = 0;
if (undefined !== prev_lsr && undefined !== next_lsr) {
var middle = Math.round((prev_lsr + next_lsr) / 2);
current_lsr = prev_lsr + middle;
if (undefined === current_rowsperpage) {
current_rowsperpage = middle;
}
} else {
if (undefined === prev_lsr) {
current_lsr = 0;
if (undefined === current_rowsperpage) {
current_rowsperpage = next_lsr;
}
} else { // next_lsr === undefined
if (undefined !== current_rowsperpage) {
current_lsr = prev_lsr + current_rowsperpage;
} else {
current_lsr = prev_lsr;
}
}
}
if (0 > current_lsr) {
current_lsr = 0;
}
if (undefined === current_rowsperpage) {
current_rowsperpage = 250;
}
console.log('Counters:');
console.log('current_rowsperpage : ' + current_rowsperpage);
console.log('prev_lsr : ' + prev_lsr);
console.log('next_lsr : ' + next_lsr);
console.log('current_lsr : ' + current_lsr);
if (1000 == current_rowsperpage) {
$this.prepend('<span>Showing 1000 records per page</span>&nbsp;|&nbsp;');
} else {
// Add rowsperpage
url = url.replace(/([&?]([^&]*)%3Alsr)=[0-9]*/g, "$1&$2%3Arowsperpage=0"); // If delimeter - %3A
url = url.replace(/(&lsr=[0-9]*)/g, "$1&rowsperpage=0"); // If delimeter - &
// Chnage lsr & rowsperpage
url = url.replace(/((%3A|[&?])rowsperpage)=[0-9]*/g, "$1=1000");
url = url.replace(/((%3A|[&?])lsr)=[0-9]*/g, "$1=" + current_lsr);
$this.prepend('<a href="' + url + '">Show 1000 records per page</a>&nbsp;|&nbsp;');
}
}
}
});
var links = $('.bPageBlock .pbBody > .fewerMore a:first-child');
if (links.length) {
links.each(function () {
var $this = $(this);
var url = $this.attr('href');
var rowsperpage = utils.getRowsperpageFromUrl(url);
if (undefined !== rowsperpage) {
if (
(990 == rowsperpage && $this.find('.fewerArrow').length) ||
(1010 == rowsperpage && $this.find('.moreArrow').length)
) {
$this.parent().append('<br/><span style="color:grey;">Showing 1000 records per page</span>');
} else {
url = url.replace(/((%3A|[&?])rowsperpage)=[0-9]*/g, "$1=1000");
$this.parent().append('<br/><a href="' + url + '">Show 1000 records per page</a>');
}
}
});
}
},
showLineNumbersInTables: function () {
var $bodyCell = $('#bodyCell');
$bodyCell.find('table.list > thead, table.list > tbody').children('tr.headerRow').children('th:first-child').each(function () {
$(this).attr('line-number', '#');
});
$bodyCell.find('table.list > tbody').each(function () {
var index = 1;
$(this).children('tr:not(.headerRow)').children('td:first-child').each(function () {
$(this).attr('line-number', index);
index++;
});
});
}
};
\ No newline at end of file
{
"manifest_version": 2,
"name": "Salesforce UI Improver",
"description": "This extension makes Salesforce User Interface better!",
"version": "0.1",
"options_ui": {
"page": "html/popup.html",
"chrome_style": true
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"browser_action": {
"default_icon": "images/icon.png",
"default_popup": "html/popup.html"
},
"content_scripts": [
{
"matches": ["https://*.salesforce.com/*"],
"css": ["css/scripts.css"],
"js": [
"js/jquery-2.2.4.min.js",
"js/scripts.js",
"js/script-manager.js"
],
"run_at": "document_end"
}
],
"permissions": [
"https://*.salesforce.com/*",
"storage"
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment