There are 69 previous versions of this script.
// ==UserScript==
// @name userscripts.org alternate CSS
// @namespace http://userscripts.org/scripts/show/34698
// @version 1.017
// @include http://userscripts.org/*
// @include https://userscripts.org/*
// ==/UserScript==
//======== Useful Sub-routines =====
function addGlobalStyle(css) {
var head_elem=document.evaluate('//head', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (!head_elem) { return; }
var style_elem=document.createElement('style');
style_elem.setAttribute('type','text/css');
style_elem.textContent=css;
head_elem.appendChild(style_elem);
}
function remove_element(elementname) {
var el=document.getElementById(elementname);
if(el) { el.parentNode.removeChild(el); }
}
function getAbsoluteTop(element) {
var AbsTop=0;
while (element) { AbsTop=AbsTop+element.offsetTop; element=element.offsetParent; }
return(AbsTop);
}
//======== Routines ================
// more_rows_in_script_description_extended()
function more_rows_in_script_description_extended() {
var elem=document.evaluate('//textarea[@id="script_description_extended"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if(elem) { elem.setAttribute('rows','40'); }
}
// bind_change_wrap()
const WRAP_TO_ON = 'Enable Word Wrap';
const WRAP_TO_OFF = 'Disable Word Wrap';
function change_wrap(wrap) {
var elems=document.evaluate('//pre', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if(elems) {
var elems_lg=elems.snapshotLength;
for(var h=0;h<elems_lg;h++) {
var elem=elems.snapshotItem(h);
if(elem) {
if(wrap) { elem.setAttribute('wrap','on'); }
else { elem.setAttribute('wrap','off'); }
}
}
}
}
function toggle_wrap() {
var btElem1=document.getElementById('wrap-button1');
var btElem2=document.getElementById('wrap-button2');
if(btElem1) {
if(btElem1.textContent==WRAP_TO_ON) {
change_wrap(true);
btElem1.textContent=WRAP_TO_OFF;
if(btElem2) { btElem2.textContent=WRAP_TO_OFF; }
} else {
change_wrap(false);
btElem1.textContent=WRAP_TO_ON;
if(btElem2) { btElem2.textContent=WRAP_TO_ON; }
}
}
}
function create_wrap_buttons(elem) {
elem.setAttribute('wrap','off');
var btElem1=document.createElement('button');
btElem1.setAttribute('style','width:180px;');
btElem1.textContent=WRAP_TO_ON;
var btElem2=btElem1.cloneNode(true);
btElem1.setAttribute('id','wrap-button1');
btElem2.setAttribute('id','wrap-button2');
btElem1.addEventListener('click',toggle_wrap,true);
btElem2.addEventListener('click',toggle_wrap,true);
elem.parentNode.insertBefore(btElem1, elem);
elem.parentNode.insertBefore(btElem2, elem.nextSibbling);
}
function bind_change_wrap() {
var elem=document.getElementById('scripts-review');
if(elem) {
elem=document.getElementById('source');
if(!elem) { elem=document.evaluate('//pre',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; }
if(elem) { create_wrap_buttons(elem); }
return;
}
var elem=document.getElementById('scripts-diff');
if(elem) {
elem=document.evaluate('//pre',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
if(elem) { create_wrap_buttons(elem); }
return;
}
}
function scrollToElem(Elem,way) {
var newvalue=getAbsoluteTop(Elem);
if(!way) { newvalue=Math.max(0,newvalue-document.documentElement.clientHeight+Elem.offsetHeight); }
scrollTo(document.documentElement.scrollLeft,newvalue);
}
function createBottomTop(div1,div2) {
var Elem1=document.createElement('a');
Elem1.textContent=String.fromCharCode(8659);
Elem1.setAttribute('href','#bottom_pagination');
Elem1.setAttribute('title','Bottom pagination');
Elem1.setAttribute('style','margin-right:4px; cursor:pointer;');
div1.insertBefore(Elem1,div1.firstChild);
div1.setAttribute('id','top_pagination');
var Elem2=document.createElement('a');
Elem2.textContent=String.fromCharCode(8657);
Elem2.setAttribute('href','#top_pagination');
Elem2.setAttribute('title','Top pagination');
Elem2.setAttribute('style','margin-right:4px; cursor:pointer;');
div2.insertBefore(Elem2,div2.firstChild);
div2.setAttribute('id','bottom_pagination');
Elem1.addEventListener('click',function(event) { scrollToElem(div2,false); event.preventDefault(); },true);
Elem2.addEventListener('click',function(event) { scrollToElem(div1,true ); event.preventDefault(); },true);
}
function duplicate_pagination() {
var divs=document.evaluate('//div[contains(@class,"pagination")]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
if(divs) {
var lg=divs.snapshotLength;
if(lg==2) { createBottomTop(divs.snapshotItem(0),divs.snapshotItem(1)); }
if(lg!=1) { return; }
var div=divs.snapshotItem(0);
var pdiv=div.parentNode;
var content=document.evaluate('.//table',pdiv,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
if(!content) { content=document.evaluate('.//ul[not(contains(@id,"script-nav"))]',pdiv,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; }
if(!content) { return; }
var curs=pdiv.firstChild;
var after=false;
while(true) {
if(curs==div) { break; }
if(curs==content) { after=true; break; }
curs=curs.nextSibling;
if(!curs) { return; }
}
var pag2=div.cloneNode(true);
if(after) {
pdiv.insertBefore(pag2,content);
createBottomTop(pag2,div);
} else {
pdiv.insertBefore(pag2,content.nextSibling);
createBottomTop(div,pag2);
}
}
}
function AddBottomTop() {
var navdiv =document.evaluate('//div[@id="navbox"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
var footdiv=document.evaluate('//div[@id="footer"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
if(!navdiv || !footdiv) { return; }
var div1=document.createElement('div');
div1.setAttribute('class','alt_topbottom');
div1.setAttribute('style','float:left; position:absolute;');
var Elem1=document.createElement('a');
//Elem1.textContent=String.fromCharCode(8659);
Elem1.setAttribute('href','#footer');
Elem1.setAttribute('title','Bottom');
Elem1.setAttribute('style','position: absolute; top:5px; left:5px; background:url(/images/clearbits/arrow1_s.gif) 1px 1px; padding:1px !important; margin:0 !important');
div1.appendChild(Elem1);
Elem1.addEventListener('click',function(event) { scrollTo(document.documentElement.scrollLeft,document.documentElement.scrollHeight); event.preventDefault(); },true);
navdiv.insertBefore(div1,navdiv.firstChild);
var div2=document.createElement('div');
div2.setAttribute('class','alt_topbottom');
div2.setAttribute('style','float:left; position:absolute; z-index:1;');
var Elem2=document.createElement('a');
//Elem2.textContent=String.fromCharCode(8657);
Elem2.setAttribute('href','#header');
Elem2.setAttribute('title','Top');
Elem2.setAttribute('style','position: absolute; top:33px; left:5px; background:url(/images/clearbits/arrow1_n.gif) 1px 1px; padding:1px !important; margin:0 !important');
div2.appendChild(Elem2);
Elem2.addEventListener('click',function(event) { scrollTo(document.documentElement.scrollLeft,0); event.preventDefault(); },true);
footdiv.parentNode.insertBefore(div2,footdiv);
}
function add_feedback_button() {
var mm=document.getElementById('mainmenu');
var uft=document.getElementById('uservoice-feedback-tab');
if(mm && uft) {
var lif=document.createElement('li');
var af =document.createElement('a');
af.setAttribute('href',uft.getAttribute('href'));
af.setAttribute('onclick',uft.getAttribute('onclick'));
af.textContent='Feedback';
lif.appendChild(af);
mm.appendChild(lif);
}
}
function add_missing_buttons() {
const LISTE={
"Jetpacks": ["/jetpacks","Scripts"]
, "Groups" : ["/groups" ,"Blog" ]
, "Guides" : ["/guides" ,"Groups" ]
}
var mm=document.getElementById('mainmenu');
if(!mm) { return; }
for(var key in LISTE) {
var data=LISTE[key];
var btn=document.evaluate('.//a[contains(text(),"'+key+'")]', mm, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if(btn) { continue; }
btn=document.evaluate('.//a[contains(text(),"'+data[1]+'")]', mm, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if(!btn) { continue; }
nav=btn.parentNode.nextSibling;
while(nav && nav.nodeName.toLowerCase()=='#text') { nav=nav.nextSibling; }
var liElem=document.createElement('li');
var aElem =document.createElement('a');
aElem.setAttribute('href',data[0]);
aElem.textContent=key;
liElem.appendChild(aElem);
btn.parentNode.parentNode.insertBefore(liElem,nav);
}
}
function extend_file_input() {
var inp=document.evaluate('//input[(@id="src") and (@type="file")]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if(inp) { inp.setAttribute('size','100'); }
}
function newTopicReplaceText() {
var aElem=document.evaluate('//a[starts-with(@href,"/topics/new?forum_id=") and starts-with(text(),"New topic")]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if(aElem) { aElem.textContent='New topic'; }
}
function addViewSource() {
var aElems=document.evaluate('//a[starts-with(@href,"/scripts/version/") and (text()="install")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if(aElems) {
for(var h=0,lg=aElems.snapshotLength;h<lg;h++) {
var aElem=aElems.snapshotItem(h);
var tEl=document.createTextNode(' | ');
var aEl=document.createElement('a');
aEl.setAttribute('href',aElem.getAttribute('href')+'?view_source');
aEl.textContent='view';
aElem.parentNode.insertBefore(aEl,aElem.nextSibling);
aElem.parentNode.insertBefore(tEl,aElem.nextSibling);
}
}
}
//*** Add top pagination
duplicate_pagination();
AddBottomTop();
//*** Add Wrap Button***
bind_change_wrap();
//*** More rows in script_description_extended
more_rows_in_script_description_extended();
//*** Move the annoying feedback button in the menu
add_feedback_button();
//*** Add the missing button in the mainmenu when not logged
add_missing_buttons();
//*** Add show source in versions page
addViewSource();
//***
extend_file_input();
newTopicReplaceText();
addGlobalStyle(''
//--- Header & Footer
+' #header #nav { width:96% !important; margin-left:28px !important; }'
+' #footer-content { width:96% !important; margin-left:30px !important; }'
+' div#footer .col { width:50% !important; }'
+' #header #nav #mainmenu li a { text-shadow:none; }'
//--- Content
+' #activity { font-size: 1.2em; font-family:Tahoma,"Lucida Grande",Arial,Helvetica,sans-serif; }'
+' #activity table td { padding-bottom:2px !important; padding-top:2px !important; }'
+' #topics { font-size: 1.2em; }'
+' #topics table { margin-bottom:0px; }'
+' #homeMenu { margin-top: -3px !important; width:auto !important; white-space:nowrap; }'
+' .container { position:relative; width:auto; margin: 0 10px; min-width:760px; }'
+' #content { float:left; position:relative; left:10px; width:79%; }'
+' #content { width:71% !important; margin-right:0 !important; }'
+' #content pre { max-width:none !important; }'
+' #right { top:5px; font-size:0.9em; right:10px; }'
+' #right { position:relative; float:right !important; width:25% !important; padding-left:0px !important; margin-left:0px !important; }'
+' #script_sidebar { padding-top:0px; }'
+' table, ul { margin-bottom:8px; }'
+' #about-summary #topics { width: 260px; }'
//--- Misc
//+' #right a { color:#0000AA !important; }'
//+' #right a:visited { color:#000066 !important }'
+' h1 {font-size:26px !important; line-height: 26px !important;}'
+' h3 {font-size:20px !important; line-height: 20px !important; padding: 2px 10px 2px 10px !important; margin-bottom:2px !important}'
+' p { margin-top: 0px; }'
+' th a:visited { color:#FFFFEE; }'
+' th a:hover { color:#FFEE00; }'
//+' p.subtitle { display:inline; }'
+' #content > p { margin-bottom:5px; margin-top:5px; }'
+' .pagination { margin-bottom:5px; margin-top:0px; }'
+' p.subtitle img { vertical-align:sub; }'
+' textarea,input[type=text] { border-right-color:#AAAAAA; border-bottom-color:#AAAAAA; }'
//--- Elements pre / blockquote / code
+' .container { font-size: 14px; width:auto; }'
+' .container pre { border-style: solid; border-color: #E0E0E0 #C0C0C0 #C0C0C0 #E0E0E0; border-width: 2px 1px 1px 3px;'
+ ' margin:6px 0; max-width:none; overflow-x:auto; font-size: 1em; }'
+' .container blockquote { border-style: solid !important; border-width:2px 1px 1px 3px !important; border-color: #CCFFBB #99DD99 #99DD99 #CCFFBB !important;'
+ ' max-width:none !important; overflow-x:auto !important; padding:5px 10px !important; margin: 6px 0 !important;'
+ ' background: #DDFFDD !important; font-family:"Lucida Grande",Tahoma,Arial,Helvetica,sans-serif; font-size:1em; }'
+' .container code { background: #DDDDDD; font-size: 1em; line-height:1.4em; padding-bottom:0.2em; padding-top:0.1em; }'
+' .container pre pre { font-size: 1em; }'
+' .container pre code { font-size: 1em; background: #D0D0D0; }'
+' .container pre blockquote { font-size: 1em; }'
+' .container code pre { font-size: 1em; }'
+' .container code code { font-size: 1em; }'
+' .container code blockquote { font-size: 1em; }'
+' .container blockquote pre { font-size: 1em; }'
+' .container blockquote code { font-size: 1em; background: #D0D0D0; }'
+' .container blockquote blockquote { font-size: 1em; }'
//--- Full width content
+' .wide #content { width:98% !important; }'
//--- Messages
+' #message_body { width: 98% !important; }'
+' #message_subject { width: 98% !important; }'
+' body.messages #content { width:98% !important; }'
+' body.messages #content .message_info { width:220px !important; }'
+' body.messages #content .message_info .date { display:block; }'
+' body.messages #content li.preview .message_preview { display:block; }'
+' body.messages #content li.preview .message_preview .message { display:block; }'
+' body.messages #content .message_info .controls { position:absolute; right:0; top:0; }'
+' body.messages #content li.full .message_full { width:98% !important; }'
//--- Div hidding
+' #uservoice-feedback-tab { display:none !important; }'
+' #clikball { display:none !important; }'
+' #uso { display:none !important; }'
//=== http://userscripts.org/
+' body#site-home #browser-news li { height: auto; margin-top:12px; min-height:16px; background-position:8px 0px !important; }'
+' body#site-home #browser-news .greasemonkey { min-height:32px; background-position:0px 0px !important; }'
+' body#site-home #browser-news .webkit { min-height:32px; background-position:0px 0px !important; }'
//=== http://userscripts.org/forums/*/topics/*
//=== http://userscripts.org/users/*/comments
//=== http://userscripts.org/users/*/script_comments
+' table.wide { table-layout:fixed; width:100%; }'
//=== http://userscripts.org/forums
//=== http://userscripts.org/scripts
//=== http://userscripts.org/users/*/scripts
+' table.wide.topics, table.wide.forums { table-layout:auto; }'
//=== http://userscripts.org/scripts/edit/*
//=== http://userscripts.org/scripts/edit_src/*
+' #script_name { width:90%; }'
+' #script_summary, #script_location, #script_homepage { width:100%; }'
//=== http://userscripts.org/groups
+' #group_list { table-layout:auto; }'
//=== http://userscripts.org/guides
+' .guides table[class=wide] { table-layout:auto; }'
//=== Wrap on/off
+' #scripts-review .container, #scripts-diff .container { display :inline-block; padding-right:16px; min-width:95%; }'
+' #scripts-review #content , #scripts-diff #content { overflow:visible !important; width:auto !important; min-width:98%; }'
+' .scripts pre[wrap=on] { white-space: pre-wrap; }'
+' .scripts pre[wrap=off] { overflow:visible !important; }'
+' .awesome, .awesome:visited { text-shadow:none; font-size:13px !important; }'
+' .awesome.orange, .awesome.orange:visited { color:#333333; background-color:#FF9900; }'
+' .awesome.orange:hover, .awesome:visited.orange:hover { color:#000000; background-color: #FF7700 ; }'
+' body.users ul.subnav li a { position:relative; }'
+' body.users ul.subnav li a span { float:none; position:absolute; margin:4px; top:0; right:0; }'
//=== Extended
+' .alt_topbottom a,.alt_topbottom a:visited { cursor:pointer; width:17px; height:16px; background-color:#FF8000 !important; border:1px solid #FFAA88;}'
+' .alt_topbottom a:hover,.alt_topbottom a:visited.alt_topbottom a:hover { cursor:pointer; width:16px; height:16px; background-color:#FF6000 !important; border:1px solid #FF9977;}'
);
