Advertisement
Som1Lse

LFE Custom Theme Userscript

Sep 21st, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Custom LFE Theme
  3. // @namespace   http://
  4. // @author      Someone else
  5. // @include     http://www.lf-empire.de/forum/*
  6. // @include     http://lf-empire.de/forum/*
  7. // @version     1.0.0
  8. // @grant       GM_addStyle
  9. // @grant       GM_getValue
  10. // @grant       GM_setValue
  11. // @grant       GM_deleteValue
  12. // @grant       GM_registerMenuCommand
  13. // @grant       unsafeWindow
  14. // @run-at      document-end
  15. // ==/UserScript==
  16.  
  17. /*
  18. window.addEventListener('DOMContentLoaded',function(e){
  19.     //fixes some issues with the editor. meant for source mode only
  20.     var x = document.getElementById('message');
  21.     if(x){
  22.         MessageString = x.value;
  23.         MessageEditor = x;
  24.  
  25.         var script = document.createElement('script');
  26.         script.type = 'text/javascript';
  27.         script.textContent = '('+function(){
  28.             if(MessageEditor.nextSibling && MessageEditor.nextSibling.children[2]){
  29.                 MessageEditor.nextSibling.children[2].value = MessageString;
  30.                 MessageEditor.value = MessageString;
  31.             }
  32.         }+')();';
  33.  
  34.         document.body.appendChild(script);
  35.     }
  36. },false);
  37. */
  38.  
  39. 'use strict'
  40.  
  41. GM_addStyle('#logo {'+
  42.                 'padding: 0px !important;'+
  43.             '}'+
  44.            
  45.             '#panel .upper a.usercp {'+
  46.                 'padding-right: 20px !important;'+
  47.                 'background: url(http://www.lf-empire.de/forum/images/headerlinks_sprite.png) no-repeat right -120px;'+
  48.                 'font-weight: bold;'+
  49.                 'margin-left: 6px;'+
  50.                 'padding-right: 20px;'+
  51.             '}'+
  52.             '#panel .lower ul.user_links {'+
  53.                 'float: left !important;'+
  54.             '}'+
  55.                
  56.             '#search input {'+
  57.                 'margin: -4px 0px !important;'+
  58.             '}'+
  59.            
  60.             '.navigation a {'+
  61.                 'font-weight: bold !important;'+
  62.             '}'+
  63.            
  64.             '.geshicode_h {'+
  65.                 'padding: 0px !important;'+
  66.                 'margin: -3px !important;'+
  67.                 'border-radius: 6px !important;'+
  68.                 'overflow: hidden !important;'+
  69.             '}'+
  70.            
  71.             '.geshicode_h>br {'+
  72.                 'display: none !important;'+
  73.             '}'+
  74.            
  75.             '.geshicode_b {'+
  76.                 'padding-left: 1px !important;'+
  77.                 'max-height: 290px !important;'+
  78.                 'border-style: none !important;'+
  79.                 'border-top-style: solid !important;'+
  80.             '}'+
  81.            
  82.             '.geshicode_b pre {'+
  83.                 'margin: 0px !important;'+
  84.             '}'+
  85.            
  86.             '#cts-closer {'+
  87.                 'background: rgba(0,0,0,0.6);'+
  88.                 'position: fixed;'+
  89.                 'top:     0px;'+
  90.                 'left:    0px;'+
  91.                 'bottom:  0px;'+
  92.                 'right:   0px;'+
  93.                 'z-index: 9000;'+
  94.             '}'+
  95.            
  96.             '#cts-main {'+
  97.                 'background: white;'+
  98.                 'border: 1px solid #000000;'+
  99.                 'border-radius: 8px;'+
  100.                 'padding: 4px;'+
  101.                 'position: fixed;'+
  102.                 'top:     128px;'+
  103.                 'left:    128px;'+
  104.                 'bottom:  128px;'+
  105.                 'right:   128px;'+
  106.                 'z-index: 9001;'+
  107.                 'overflow: auto;'+
  108.             '}'+
  109.             '#cts-main>a {'+
  110.                 'float: left;'+
  111.                 'font-size: 20pt;'+
  112.                 'font-style: bold;'+
  113.                 'border: 2px solid #ffffff;'+
  114.                 'border-radius: 4px;'+
  115.                 'outline: none;'+
  116.                 'padding: 0px 4px;'+
  117.                 'text-decoration: none;'+
  118.                 'margin: 2px;'+
  119.                 'background: #e0e0e0;'+
  120.                 'color: #000000 !important;'+
  121.                 'white-space: nowrap;'+
  122.             '}'+
  123.             '#cts-main>a.selected {'+
  124.                 'border-color: #000000;'+
  125.             '}'+
  126.             '#cts-main>a:hover {'+
  127.                 'float: left;'+
  128.                 'background: #808080;'+
  129.                 'color: #ffffff !important;'+
  130.             '}');
  131.            
  132. var customthemes = {
  133.     'none': {},
  134.     'Red and Black': {
  135.         'css':  'a {'+
  136.                     'color: #bc0000 !important;'+
  137.                 '}'+
  138.                
  139.                 'html, body {'+
  140.                     'height: 100%;'+
  141.                     'background: #0c0c0c !important;'+
  142.                 '}'+
  143.                
  144.                 '#content {'+
  145.                     'background: none !important;'+
  146.                     'padding-bottom: 80px !important;'+
  147.                 '}'+
  148.                
  149.                 '#overview.error pre {'+
  150.                     'margin: 0px;'+
  151.                 '}'+
  152.                
  153.                 '#container {'+
  154.                     'min-height: 100%;'+
  155.                     'position: relative;'+
  156.                     'color: #ffffff !important'+
  157.                 '}'+
  158.                
  159.                 '#footer {'+
  160.                     'width: 100%;'+
  161.                     'position: absolute;'+
  162.                     'left: 0px;'+
  163.                     'bottom: 0px;'+
  164.                 '}'+
  165.                
  166.                 '#panel {'+
  167.                     'background: linear-gradient(#202020,#101010) !important;'+
  168.                     'border-top: 1px solid #000000 !important;'+
  169.                     'border-bottom: 1px solid #000000 !important;'+
  170.                 '}'+
  171.                
  172.                 '#panel .upper, #panel .lower {'+
  173.                     'color: #999999 !important;'+
  174.                     'background: none !important;'+
  175.                     'border-top: none !important;'+
  176.                     'border-bottom: none !important;'+
  177.                 '}'+
  178.                
  179.                 'div#logo {'+
  180.                     'background: url(http://lf-empire.de/forum/images/header_back.jpg) no-repeat !important;'+
  181.                     'border-bottom: none !important;'+
  182.                 '}'+
  183.                
  184.                 '.pm_alert {'+
  185.                     'border: 1px solid #000000 !important;'+
  186.                     'background: #181818 !important;'+
  187.                 '}'+
  188.            
  189.                 '.navigation, .navigation .active {'+
  190.                     'color: #ffffff !important;'+
  191.                 '}'+
  192.                
  193.                 'table {'+
  194.                     'border-collapse: collapse;'+
  195.                     'color: #c0c0c0 !important;'+
  196.                 '}'+
  197.            
  198.                 '.tborder td {'+
  199.                     'border-radius: 0px !important;'+
  200.                     'border: 1px solid #000000 !important;'+
  201.                 '}'+
  202.            
  203.                 '#overview .thead {'+
  204.                     'border-left: none !important;'+
  205.                     'border-right: none !important;'+
  206.                 '}'+
  207.            
  208.                 '#overview td {'+
  209.                     'padding: 6px;'+
  210.                 '}'+
  211.                
  212.                 '.clt-tborder_outer {'+
  213.                     'border-radius: 8px;'+
  214.                     'border: 1px solid #000000;'+
  215.                     'overflow: hidden;'+
  216.                     'display: block;'+
  217.                 '}'+
  218.                
  219.                 '.tborder {'+
  220.                     'background: none !important;'+
  221.                 '}'+
  222.                
  223.                 '.tborder, .tborder tr {'+
  224.                     'border: none !important;'+
  225.                     'padding: 0px !important;'+
  226.                 '}'+
  227.                
  228.                 '.tborder .thead {'+
  229.                     'background: linear-gradient(#d60000,#a70000) !important;'+
  230.                     'border: none !important;'+
  231.                 '}'+
  232.                
  233.                 '.thead a, .upper a, #panel .lower a, .spoiler_header a{'+
  234.                     'color: #ffffff !important;'+
  235.                 '}'+
  236.                
  237.                 '.tborder .tcat {'+
  238.                     'background: linear-gradient(#202020,#101010) !important;'+
  239.                 '}'+
  240.                
  241.                 '.tborder tbody tr:last-child>td {'+
  242.                     'border-bottom: none !important;'+
  243.                 '}'+
  244.                 '.tborder tbody tr>td:first-child {'+
  245.                     'border-left: none !important;'+
  246.                 '}'+
  247.                 '.tborder tbody tr>td:last-child {'+
  248.                     'border-right: none !important;'+
  249.                 '}'+
  250.                
  251.                 '.post {'+
  252.                     'background: #202020 !important;'+
  253.                 '}'+
  254.                
  255.                 '.post .post_author {'+
  256.                     'background: #303030 !important;'+
  257.                 '}'+
  258.                
  259.                 '.post hr {'+
  260.                     'background: #808080 !important;'+
  261.                 '}'+
  262.                
  263.                 '.post.classic .post_author {'+
  264.                     'margin: -15px 1% 15px 0 !important;'+
  265.                     'border: 1px solid #000000 !important;'+
  266.                     'border-top: none !important;'+
  267.                     'border-left: none !important;'+
  268.                     'border-radius: 0px 0px 6px 0px !important;'+
  269.                 '}'+
  270.                
  271.                 '.post.classic .post_author,'+
  272.                 '.post .post_author div.author_statistics {'+
  273.                     'color: #909090 !important;'+
  274.                 '}'+
  275.                
  276.                 '.post .post_author div.author_statistics a:link,'+
  277.                 '.post .post_author div.author_statistics a:visited {'+
  278.                     'color: #c0c0c0 !important;'+
  279.                 '}'+
  280.                
  281.                 '.post.classic .post_author div.author_statistics {'+
  282.                     'border-top: 1px dotted #a00000 !important;'+
  283.                 '}'+
  284.                
  285.                 '.post .post_head {'+
  286.                     'border-bottom: 1px dotted #c0c0c0 !important;'+
  287.                 '}'+
  288.                
  289.                 '.post_controls {'+
  290.                     'background: linear-gradient(#282828,#202020) !important;'+
  291.                     'border-bottom: 1px solid #000000 !important;'+
  292.                 '}'+
  293.                
  294.                 '.post:last-child .post_controls {'+
  295.                     'border-bottom: none !important;'+
  296.                 '}'+
  297.                
  298.                 'blockquote, .codeblock {'+
  299.                     'border: 1px solid #000000 !important;'+
  300.                     'background: #181818 !important;'+
  301.                 '}'+
  302.                
  303.                 'blockquote cite, .codeblock .title {'+
  304.                     'border-bottom: 1px solid #000000 !important;'+
  305.                 '}'+
  306.                
  307.                 '.spoiler {'+
  308.                     'background: #101010 !important;'+
  309.                 '}'+
  310.                
  311.                 '.clt-modnotice_outer {'+
  312.                     'min-width: 700px;'+
  313.                     'width: 70%;'+
  314.                 '}'+
  315.                
  316.                 '.clt-modnotice_outer > .modnotice {'+
  317.                     'width: 100%;'+
  318.                 '}'+
  319.                
  320.                 '.modnotice_notice {'+
  321.                     'background: #303030 !important;'+
  322.                     'color: #c0c0c0 !important;'+
  323.                 '}'+
  324.                
  325.                 'td.trow1 td, td.trow2 td {'+
  326.                     'border: none !important;'+
  327.                 '}'+
  328.                
  329.                 '.trow1 {'+
  330.                     'background: #202020 !important;'+
  331.                 '}'+
  332.                
  333.                 '.trow2 {'+
  334.                     'background: #282828 !important;'+
  335.                 '}'+
  336.                
  337.                 '.trow_sep {'+
  338.                     'background: #101010 !important;'+
  339.                     'color: #e0e0e0 !important;'+
  340.                 '}'+
  341.                
  342.                 '.tborder td.tfoot {'+
  343.                     'background: linear-gradient(#282828,#181818) !important;'+
  344.                     'border-top: none !important;'+
  345.                 '}'+
  346.                
  347.                 '.button, .postbit_buttons>a {'+
  348.                     'background: linear-gradient(#d60000, #a70000) !important;'+
  349.                     'border: 1px solid #000000 !important;'+
  350.                     'color: #ffffff !important;'+
  351.                 '}'+
  352.                
  353.                 '.spoiler_header:after {'+
  354.                     'background: linear-gradient(#d60000,#a70000) !important;'+
  355.                 '}'+
  356.                
  357.                 '.userregistered, .useradvanced {'+
  358.                     'color: #0072bc !important;'+
  359.                 '}'+
  360.                
  361.                 '#footer {'+
  362.                     'border-top: 1px solid #000000 !important;'+
  363.                     'background: linear-gradient(#202020,#101010) !important;'+
  364.                 '}'+
  365.                
  366.                 '#footer .upper {'+
  367.                     'border: none !important;'+
  368.                     'background: none !important;'+
  369.                 '}',
  370.         'func': function(){
  371.             var x = document.getElementById('overview');
  372.             if(x && unsafeWindow.req){
  373.                 var el1 = document.createElement('div');
  374.                 el1.style.display = 'none';
  375.                 el1.style.className = 'clt-tborder_outer';
  376.                 el1.style.marginBottom = '18px';
  377.                
  378.                
  379.                 x.parentNode.insertBefore(el1,x);
  380.                
  381.                 el1.appendChild(x);
  382.                
  383.                 var otable = document.createElement('table');
  384.                 otable.className = 'tborder';
  385.                 otable.width = '100%';
  386.                
  387.                 var othead = document.createElement('thead');
  388.                
  389.                 var cookie = unsafeWindow.Cookie.get('collapsed');
  390.                 var overviewcollapsed = false;
  391.                 if(cookie) overviewcollapsed = cookie.split('|').indexOf('overviewtable') !== -1;
  392.                
  393.                 var otr = document.createElement('tr');
  394.                 var otd = document.createElement('td');
  395.                 otd.className = 'thead';
  396.                 otd.style.width = '65%';
  397.                 otd.paddingBottom = '7px';
  398.                
  399.                 var odiv = document.createElement('div');
  400.                 var ostrong = document.createElement('strong');
  401.                 ostrong.textContent = 'Newest threads';
  402.                
  403.                 odiv.appendChild(ostrong);
  404.                 otd.appendChild(odiv);
  405.                 otr.appendChild(otd);
  406.                
  407.                 otd = document.createElement('td');
  408.                 if(overviewcollapsed){
  409.                     otd.className = 'thead thead_collapsed tcat_collapse_collapsed';
  410.                 }else{
  411.                     otd.className = 'thead';
  412.                 }
  413.                 otd.paddingBottom = '7px';
  414.                 otd.style.width = '35%';
  415.                
  416.                 odiv = document.createElement('div');
  417.                 odiv.className = 'expcolimage';
  418.                
  419.                 var oimg = document.createElement('img');
  420.                 oimg.id = 'overviewtable_img';
  421.                 oimg.className = 'expander';
  422.                 if(overviewcollapsed){
  423.                     oimg.title = '[+]';
  424.                     oimg.alt = '[+]';
  425.                     oimg.src = 'http://www.lf-empire.de/forum/images/collapse_collapsed.png';
  426.                 }else{
  427.                     oimg.title = '[-]';
  428.                     oimg.alt = '[-]';
  429.                     oimg.src = 'http://www.lf-empire.de/forum/images/collapse.png';
  430.                 }
  431.                 oimg.style.cursor = 'pointer';
  432.                
  433.                 odiv.appendChild(oimg);
  434.                 otd.appendChild(odiv);
  435.                
  436.                 odiv = document.createElement('div');
  437.                 ostrong = document.createElement('strong');
  438.                 ostrong.textContent = 'Newest posts';
  439.                
  440.                 odiv.appendChild(ostrong);
  441.                 otd.appendChild(odiv);
  442.                
  443.                 otr.appendChild(otd);
  444.                 othead.appendChild(otr);
  445.                 otable.appendChild(othead);
  446.                 x.appendChild(otable);
  447.                
  448.                 unsafeWindow.dooverview = exportFunction(function(){
  449.                     unsafeWindow.req.open('GET','xmlhttp.php?action=overview');
  450.                     unsafeWindow.req.send(null);
  451.                 },unsafeWindow);
  452.            
  453.                 unsafeWindow.req.onreadystatechange = exportFunction(function(){
  454.                     var req = unsafeWindow.req;
  455.                     if(req.readyState === req.DONE){
  456.                         var parser = new DOMParser();
  457.                         var xml = parser.parseFromString(req.responseText.replace(/<br \/>/gi,''),'application/xml');
  458.                        
  459.                         var x = document.getElementById('overview');
  460.                        
  461.                         x.parentNode.style.display = 'block';
  462.                        
  463.                         if(xml.children.length === 0 || !xml.children[0] || xml.children[0].nodeName === 'parsererror'){
  464.                             var el = xml.createElement('pre');
  465.                             var y = xml.children[0].children[0];
  466.                             el.innerHTML = y.innerHTML;
  467.                             xml.children[0].insertBefore(el,y);
  468.                             xml.children[0].removeChild(y);
  469.                             x.className = 'error';
  470.                             x.innerHTML = xml.children[0].innerHTML;
  471.                             x.parentNode.className = '';
  472.                             return;
  473.                         }
  474.                        
  475.                         x.parentNode.className = 'clt-tborder_outer';
  476.                        
  477.                         var cookie = unsafeWindow.Cookie.get('collapsed');
  478.                         var overviewcollapsed = false;
  479.                         if(cookie) overviewcollapsed = cookie.split('|').indexOf('overviewtable') !== -1;
  480.                        
  481.                         var otable = document.createElement('table');
  482.                         otable.className = 'tborder';
  483.                         otable.width = '100%';
  484.                        
  485.                         var othead = document.createElement('thead');
  486.                        
  487.                         var otr = document.createElement('tr');
  488.                         var otd = document.createElement('td');
  489.                         otd.className = 'thead';
  490.                         otd.colSpan = '3';
  491.                         otd.style.width = '65%';
  492.                        
  493.                         var odiv = document.createElement('div');
  494.                         var ostrong = document.createElement('strong');
  495.                         ostrong.textContent = 'Newest threads';
  496.                        
  497.                         odiv.appendChild(ostrong);
  498.                         otd.appendChild(odiv);
  499.                         otr.appendChild(otd);
  500.                        
  501.                         otd = document.createElement('td');
  502.                         if(overviewcollapsed){
  503.                             otd.className = 'thead thead_collapsed tcat_collapse_collapsed';
  504.                         }else{
  505.                             otd.className = 'thead';
  506.                         }
  507.                         otd.colSpan = '2';
  508.                         otd.style.width = '35%';
  509.                        
  510.                         odiv = document.createElement('div');
  511.                         odiv.className = 'expcolimage';
  512.                        
  513.                         var oimg = document.createElement('img');
  514.                         oimg.id = 'overviewtable_img';
  515.                         oimg.className = 'expander';
  516.                         if(overviewcollapsed){
  517.                             oimg.title = '[+]';
  518.                             oimg.alt = '[+]';
  519.                             oimg.src = 'http://www.lf-empire.de/forum/images/collapse_collapsed.png';
  520.                         }else{
  521.                             oimg.title = '[-]';
  522.                             oimg.alt = '[-]';
  523.                             oimg.src = 'http://www.lf-empire.de/forum/images/collapse.png';
  524.                         }
  525.                         oimg.style.cursor = 'pointer';
  526.                         oimg.onclick = function(e){
  527.                             var element = unsafeWindow.$(e.target);
  528.                        
  529.                             //from general.js
  530.                             var expandedItem = unsafeWindow.$('#overviewtable_e');
  531.                            
  532.                             if(expandedItem.length){
  533.                                 if(expandedItem.is(':hidden')){// Expanding
  534.                                     expandedItem.toggle('fast');
  535.                                     element.attr('src',element.attr('src').replace('collapse_collapsed.png','collapse.png'))
  536.                                                        .attr('alt','[-]')
  537.                                                        .attr('title','[-]');
  538.                                     element.parent().parent('td').removeClass('tcat_collapse_collapsed');
  539.                                     element.parent().parent('.thead').removeClass('thead_collapsed');
  540.                                     unsafeWindow.expandables.saveCollapsed('overviewtable');
  541.                                 }else{// Collapsing
  542.                                     expandedItem.toggle('fast');
  543.                                     element.attr('src',element.attr('src').replace('collapse.png','collapse_collapsed.png'))
  544.                                                        .attr('alt','[+]')
  545.                                                        .attr('title','[+]');
  546.                                     element.parent().parent('td').addClass('tcat_collapse_collapsed');
  547.                                     element.parent().parent('.thead').addClass('thead_collapsed');
  548.                                     unsafeWindow.expandables.saveCollapsed('overviewtable',1);
  549.                                 }
  550.                             }
  551.                             return;
  552.                         };
  553.                        
  554.                         odiv.appendChild(oimg);
  555.                         otd.appendChild(odiv);
  556.                        
  557.                         odiv = document.createElement('div');
  558.                         ostrong = document.createElement('strong');
  559.                         ostrong.textContent = 'Newest posts';
  560.                        
  561.                         odiv.appendChild(ostrong);
  562.                         otd.appendChild(odiv);
  563.                         otr.appendChild(otd);
  564.                         othead.appendChild(otr);
  565.                         otable.appendChild(othead);
  566.                        
  567.                         var otbody = document.createElement('tbody');
  568.                         otbody.id = 'overviewtable_e';
  569.                         if(overviewcollapsed) otbody.style.display = 'none';
  570.                        
  571.                         var t1 = xml.children[0].children[1].children[0].children[0].children[0];
  572.                         var t2 = xml.children[0].children[1].children[0].children[1].children[0];
  573.  
  574.                         for(var i = 1;i<Math.max(t1.children.length,t2.children.length);++i){
  575.                             otr = document.createElement('tr');
  576.                             if(i === 1){
  577.                                 otr.className = 'tcat';
  578.                             }else if(i%2 === 0){
  579.                                 otr.className = 'trow1';
  580.                             }else{
  581.                                 otr.className = 'trow2';
  582.                             }
  583.                          
  584.                             var html = '';
  585.                             if(t1.children[i]){
  586.                                 html += t1.children[i].innerHTML;
  587.                                 /*for(var j = 0;j<t1.children[i].children.length;++j){
  588.                                     var el = t1.children[i].children[j];
  589.                                     otd = document.createElement('td');
  590.                                     if(el.attributes['colspan']) otd.colSpan = el.attributes['colspan'].value;
  591.                                     if(el.attributes['class']) otd.className = el.attributes['class'].value;
  592.                                    
  593.                                     otr.appendChild(otd);
  594.                                 }*/
  595.                             }else html += '<td>/td><td>/td><td>/td>';
  596.                             if(t2.children[i]){
  597.                                 html += t2.children[i].innerHTML;
  598.                                 /*for(var j = 0;j<t2.children[i].children.length;++j){
  599.                                     var el = t2.children[i].children[j];
  600.                                     otd = document.createElement('td');
  601.                                     if(el.attributes['colspan']) otd.colSpan = el.attributes['colspan'].value;
  602.                                     if(el.attributes['class']) otd.className = el.attributes['class'].value;
  603.                                    
  604.                                     otr.appendChild(otd);
  605.                                 }*/
  606.                             }else html += '<td>/td><td>/td>';
  607.                            
  608.                             otr.innerHTML = html;
  609.                          
  610.                             otbody.appendChild(otr);
  611.                         }
  612.                        
  613.                         otable.appendChild(otbody);
  614.                        
  615.                         var y = xml.children[0].children[1];
  616.                         t1 = y.children[0].children[0].children[0];
  617.                         t2 = y.children[0].children[1].children[0];
  618.                        
  619.                         while(x.firstChild) x.removeChild(x.firstChild);
  620.                        
  621.                         x.appendChild(otable);
  622.                        
  623.                         x.className = '';
  624.                     }
  625.                 },unsafeWindow.req);
  626.             }
  627.            
  628.             x = document.querySelectorAll('.tborder');
  629.             for(var i = 0;i<x.length;++i){
  630.                 if(x[i].parentNode.id === 'overview') continue;
  631.                
  632.                 var el1 = document.createElement('div');
  633.                 for(var j = 0;j<x[i].classList.length;++j){
  634.                     el1.classList.add('clt-'+x[i].classList[j]+'_outer');
  635.                 }
  636.                 if(x[i].classList.contains('clear')) el1.classList.add('clear');
  637.                
  638.                 x[i].parentNode.insertBefore(el1,x[i]);
  639.                
  640.                 el1.appendChild(x[i]);
  641.             }
  642.            
  643.             x = document.querySelector('#content .wrapper');
  644.             if(x){
  645.                 while(x.lastElementChild.nodeName === 'BR') x.removeChild(x.lastElementChild);
  646.             }
  647.         }
  648.     }
  649. };
  650.  
  651. var ct = GM_getValue('customtheme');
  652. if(!customthemes[ct]) ct = 'none';
  653.  
  654. var customtheme = customthemes[ct];
  655.  
  656. if(customtheme.css) GM_addStyle(customtheme.css);
  657.  
  658. var theme,cts1,cts2,cta;
  659.  
  660. GM_registerMenuCommand('Set custom theme',function(){
  661.     if(!theme) return;
  662.    
  663.     if(cts1 && cts2){
  664.         cts1.style.display = 'block';
  665.         cts2.style.display = 'block';
  666.         return;
  667.     }
  668.    
  669.     cts1 = document.createElement('div');
  670.     cts1.id = 'cts-closer';
  671.    
  672.     cts1.addEventListener('click',function(e){
  673.         cts1.style.display = 'none';
  674.         cts2.style.display = 'none';
  675.     },false);
  676.    
  677.     cts2 = document.createElement('div');
  678.     cts2.id = 'cts-main';
  679.    
  680.     for(var a in customthemes){
  681.         var x = document.createElement('a');
  682.         x.href = 'javascript:void(0)';
  683.         x.innerHTML = a;
  684.        
  685.         if(a === ct){
  686.             cta = x;
  687.             x.className = 'selected';
  688.         }
  689.        
  690.         x.addEventListener('click',function(e){
  691.             e.preventDefault();
  692.            
  693.             if(e.target === cta) return;
  694.            
  695.             cta.className = '';
  696.             e.target.className = 'selected';
  697.            
  698.             cta = e.target;
  699.            
  700.             GM_setValue('customtheme',e.target.innerHTML);
  701.         },false);
  702.        
  703.         cts2.appendChild(x);
  704.     }
  705.    
  706.     document.body.appendChild(cts1);
  707.     document.body.appendChild(cts2);
  708. });
  709.  
  710. function OnLoad(){
  711.     var stylesheets = document.head.querySelectorAll('link[href^="http://www.lf-empire.de/forum/cache/themes/"]');
  712.    
  713.     var stylenames = [];
  714.     for(var i = 0;i<stylesheets.length;++i){
  715.         stylenames.push(stylesheets[i].href.substr(43,stylesheets[i].href.lastIndexOf('/')-43));
  716.     }
  717.    
  718.     if(stylenames[0] === 'theme14'){
  719.         theme = 'MyBB Theme';
  720.     }else if(stylenames[0] === 'theme17'){
  721.         theme = 'LFE v3';
  722.     }
  723.    
  724.     if(!theme) return;
  725.    
  726.     if(customtheme.func) customtheme.func();
  727.    
  728.     if(theme == 'MyBB Theme'){
  729.         var x = document.querySelector('#logo img');
  730.         if(x) x.src = 'http://www.lf-empire.de/forum/images/LFEv3/logo.png';
  731.     }else if(theme === 'LFE v3'){
  732.         GM_addStyle('.menu.top_links {'+
  733.                         'margin: -14px 5px -61px 0px !important;'+
  734.                     '}'+
  735.                    
  736.                     '#panel .lower {'+
  737.                         'box-shadow: none !important;'+
  738.                     '}');
  739.     }
  740.    
  741.     var x = document.querySelector('#panel .lower ul.panel_links a.usercp');
  742.     var y = document.querySelector('#panel .upper a.logout');
  743.     if(x && y){
  744.         x.parentNode.parentNode.parentNode.removeChild(x.parentNode.parentNode);
  745.         y.parentNode.insertBefore(x,y);
  746.     }
  747.    
  748.     x = document.querySelector('.navigation');
  749.     if(x){
  750.         for(var i = 0;i<x.childNodes.length;++i){
  751.             if(x.childNodes[i].nodeType === x.TEXT_NODE) x.childNodes[i].textContent = x.childNodes[i].textContent.replace(/›/g,'/');
  752.         }
  753.        
  754.         var y = x.querySelectorAll('br');
  755.         for(var i = 0;i<y.length;++i){
  756.             x.removeChild(y[i]);
  757.         }
  758.        
  759.         y = x.querySelector('img:last-of-type');
  760.        
  761.         if(y){
  762.             x.replaceChild(document.createTextNode(' / '),y);
  763.         }
  764.     }
  765. }
  766. OnLoad();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement