Commit 17a5671c authored by Peter Walter's avatar Peter Walter
Browse files

version 1.5

parent 6810cab4
......@@ -4,7 +4,7 @@
// @description Add some shortcut links to RT
// @match https://rt.ebi.ac.uk/*
// @include https://rt.ebi.ac.uk/extserv/*
// @version 1.4
// @version 1.5
// @updateURL http://www.ebi.ac.uk/~pwalter/rthelper/rthelper.user.js
// @run-at document-end
// ==/UserScript==
......@@ -16,6 +16,33 @@ if (!String.prototype.trim) {
String.prototype.trim=function(){return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');};
}
if (typeof GM_deleteValue == 'undefined') {
GM_deleteValue = function(name) {
localStorage.removeItem(name);
}
GM_getValue = function(name, defaultValue) {
var value = localStorage.getItem(name);
if (!value)
return defaultValue;
var type = value[0];
value = value.substring(1);
switch (type) {
case 'b':
return value == 'true';
case 'n':
return Number(value);
default:
return value;
}
}
GM_setValue = function(name, value) {
value = (typeof value)[0] + value;
localStorage.setItem(name, value);
}
}
/**
* Get value from html element
* @param String selector
......@@ -530,6 +557,40 @@ function init() {
document.body.parentNode.className += ' browser-chrome';
}
})();
(function quickSearch() {
// get fresh set of quicksearches every time we visit homepage
if (document.location.pathname === '/extserv/') {
var links = document.querySelectorAll('.titlebox .left a');
var quickSearch = '';
for (link in links) {
if (links[link].href) {
href = links[link].href;
text = links[link].innerHTML;
quickSearch += '<a class="rthelper-button" href="' + href + '">' + text + '</a> ';
}
}
GM_setValue('quickSearch', quickSearch);
}
// insert quicksearch into top of page
quickSearch = document.createElement('div');
quickSearch.id = 'quicksearch';
quickSearch.innerHTML = GM_getValue('quickSearch', '');
body = document.getElementById('body');
skipNav = document.getElementById('skipnav');
body.insertBefore(quickSearch, skipNav);
// highlight the active search
links = document.querySelectorAll('#quicksearch a');
for (link in links) {
if (links[link].href === document.location.href) {
links[link].className += ' rthelper-active';
}
}
})();
}
......
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