Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Custom LFE Theme
- // @namespace http://
- // @author Someone else
- // @include http://www.lf-empire.de/forum/*
- // @include http://lf-empire.de/forum/*
- // @version 1.0.0
- // @grant GM_addStyle
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_deleteValue
- // @grant GM_registerMenuCommand
- // @grant unsafeWindow
- // @run-at document-end
- // ==/UserScript==
- /*
- window.addEventListener('DOMContentLoaded',function(e){
- //fixes some issues with the editor. meant for source mode only
- var x = document.getElementById('message');
- if(x){
- MessageString = x.value;
- MessageEditor = x;
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.textContent = '('+function(){
- if(MessageEditor.nextSibling && MessageEditor.nextSibling.children[2]){
- MessageEditor.nextSibling.children[2].value = MessageString;
- MessageEditor.value = MessageString;
- }
- }+')();';
- document.body.appendChild(script);
- }
- },false);
- */
- 'use strict'
- GM_addStyle('#logo {'+
- 'padding: 0px !important;'+
- '}'+
- '#panel .upper a.usercp {'+
- 'padding-right: 20px !important;'+
- 'background: url(http://www.lf-empire.de/forum/images/headerlinks_sprite.png) no-repeat right -120px;'+
- 'font-weight: bold;'+
- 'margin-left: 6px;'+
- 'padding-right: 20px;'+
- '}'+
- '#panel .lower ul.user_links {'+
- 'float: left !important;'+
- '}'+
- '#search input {'+
- 'margin: -4px 0px !important;'+
- '}'+
- '.navigation a {'+
- 'font-weight: bold !important;'+
- '}'+
- '.geshicode_h {'+
- 'padding: 0px !important;'+
- 'margin: -3px !important;'+
- 'border-radius: 6px !important;'+
- 'overflow: hidden !important;'+
- '}'+
- '.geshicode_h>br {'+
- 'display: none !important;'+
- '}'+
- '.geshicode_b {'+
- 'padding-left: 1px !important;'+
- 'max-height: 290px !important;'+
- 'border-style: none !important;'+
- 'border-top-style: solid !important;'+
- '}'+
- '.geshicode_b pre {'+
- 'margin: 0px !important;'+
- '}'+
- '#cts-closer {'+
- 'background: rgba(0,0,0,0.6);'+
- 'position: fixed;'+
- 'top: 0px;'+
- 'left: 0px;'+
- 'bottom: 0px;'+
- 'right: 0px;'+
- 'z-index: 9000;'+
- '}'+
- '#cts-main {'+
- 'background: white;'+
- 'border: 1px solid #000000;'+
- 'border-radius: 8px;'+
- 'padding: 4px;'+
- 'position: fixed;'+
- 'top: 128px;'+
- 'left: 128px;'+
- 'bottom: 128px;'+
- 'right: 128px;'+
- 'z-index: 9001;'+
- 'overflow: auto;'+
- '}'+
- '#cts-main>a {'+
- 'float: left;'+
- 'font-size: 20pt;'+
- 'font-style: bold;'+
- 'border: 2px solid #ffffff;'+
- 'border-radius: 4px;'+
- 'outline: none;'+
- 'padding: 0px 4px;'+
- 'text-decoration: none;'+
- 'margin: 2px;'+
- 'background: #e0e0e0;'+
- 'color: #000000 !important;'+
- 'white-space: nowrap;'+
- '}'+
- '#cts-main>a.selected {'+
- 'border-color: #000000;'+
- '}'+
- '#cts-main>a:hover {'+
- 'float: left;'+
- 'background: #808080;'+
- 'color: #ffffff !important;'+
- '}');
- var customthemes = {
- 'none': {},
- 'Red and Black': {
- 'css': 'a {'+
- 'color: #bc0000 !important;'+
- '}'+
- 'html, body {'+
- 'height: 100%;'+
- 'background: #0c0c0c !important;'+
- '}'+
- '#content {'+
- 'background: none !important;'+
- 'padding-bottom: 80px !important;'+
- '}'+
- '#overview.error pre {'+
- 'margin: 0px;'+
- '}'+
- '#container {'+
- 'min-height: 100%;'+
- 'position: relative;'+
- 'color: #ffffff !important'+
- '}'+
- '#footer {'+
- 'width: 100%;'+
- 'position: absolute;'+
- 'left: 0px;'+
- 'bottom: 0px;'+
- '}'+
- '#panel {'+
- 'background: linear-gradient(#202020,#101010) !important;'+
- 'border-top: 1px solid #000000 !important;'+
- 'border-bottom: 1px solid #000000 !important;'+
- '}'+
- '#panel .upper, #panel .lower {'+
- 'color: #999999 !important;'+
- 'background: none !important;'+
- 'border-top: none !important;'+
- 'border-bottom: none !important;'+
- '}'+
- 'div#logo {'+
- 'background: url(http://lf-empire.de/forum/images/header_back.jpg) no-repeat !important;'+
- 'border-bottom: none !important;'+
- '}'+
- '.pm_alert {'+
- 'border: 1px solid #000000 !important;'+
- 'background: #181818 !important;'+
- '}'+
- '.navigation, .navigation .active {'+
- 'color: #ffffff !important;'+
- '}'+
- 'table {'+
- 'border-collapse: collapse;'+
- 'color: #c0c0c0 !important;'+
- '}'+
- '.tborder td {'+
- 'border-radius: 0px !important;'+
- 'border: 1px solid #000000 !important;'+
- '}'+
- '#overview .thead {'+
- 'border-left: none !important;'+
- 'border-right: none !important;'+
- '}'+
- '#overview td {'+
- 'padding: 6px;'+
- '}'+
- '.clt-tborder_outer {'+
- 'border-radius: 8px;'+
- 'border: 1px solid #000000;'+
- 'overflow: hidden;'+
- 'display: block;'+
- '}'+
- '.tborder {'+
- 'background: none !important;'+
- '}'+
- '.tborder, .tborder tr {'+
- 'border: none !important;'+
- 'padding: 0px !important;'+
- '}'+
- '.tborder .thead {'+
- 'background: linear-gradient(#d60000,#a70000) !important;'+
- 'border: none !important;'+
- '}'+
- '.thead a, .upper a, #panel .lower a, .spoiler_header a{'+
- 'color: #ffffff !important;'+
- '}'+
- '.tborder .tcat {'+
- 'background: linear-gradient(#202020,#101010) !important;'+
- '}'+
- '.tborder tbody tr:last-child>td {'+
- 'border-bottom: none !important;'+
- '}'+
- '.tborder tbody tr>td:first-child {'+
- 'border-left: none !important;'+
- '}'+
- '.tborder tbody tr>td:last-child {'+
- 'border-right: none !important;'+
- '}'+
- '.post {'+
- 'background: #202020 !important;'+
- '}'+
- '.post .post_author {'+
- 'background: #303030 !important;'+
- '}'+
- '.post hr {'+
- 'background: #808080 !important;'+
- '}'+
- '.post.classic .post_author {'+
- 'margin: -15px 1% 15px 0 !important;'+
- 'border: 1px solid #000000 !important;'+
- 'border-top: none !important;'+
- 'border-left: none !important;'+
- 'border-radius: 0px 0px 6px 0px !important;'+
- '}'+
- '.post.classic .post_author,'+
- '.post .post_author div.author_statistics {'+
- 'color: #909090 !important;'+
- '}'+
- '.post .post_author div.author_statistics a:link,'+
- '.post .post_author div.author_statistics a:visited {'+
- 'color: #c0c0c0 !important;'+
- '}'+
- '.post.classic .post_author div.author_statistics {'+
- 'border-top: 1px dotted #a00000 !important;'+
- '}'+
- '.post .post_head {'+
- 'border-bottom: 1px dotted #c0c0c0 !important;'+
- '}'+
- '.post_controls {'+
- 'background: linear-gradient(#282828,#202020) !important;'+
- 'border-bottom: 1px solid #000000 !important;'+
- '}'+
- '.post:last-child .post_controls {'+
- 'border-bottom: none !important;'+
- '}'+
- 'blockquote, .codeblock {'+
- 'border: 1px solid #000000 !important;'+
- 'background: #181818 !important;'+
- '}'+
- 'blockquote cite, .codeblock .title {'+
- 'border-bottom: 1px solid #000000 !important;'+
- '}'+
- '.spoiler {'+
- 'background: #101010 !important;'+
- '}'+
- '.clt-modnotice_outer {'+
- 'min-width: 700px;'+
- 'width: 70%;'+
- '}'+
- '.clt-modnotice_outer > .modnotice {'+
- 'width: 100%;'+
- '}'+
- '.modnotice_notice {'+
- 'background: #303030 !important;'+
- 'color: #c0c0c0 !important;'+
- '}'+
- 'td.trow1 td, td.trow2 td {'+
- 'border: none !important;'+
- '}'+
- '.trow1 {'+
- 'background: #202020 !important;'+
- '}'+
- '.trow2 {'+
- 'background: #282828 !important;'+
- '}'+
- '.trow_sep {'+
- 'background: #101010 !important;'+
- 'color: #e0e0e0 !important;'+
- '}'+
- '.tborder td.tfoot {'+
- 'background: linear-gradient(#282828,#181818) !important;'+
- 'border-top: none !important;'+
- '}'+
- '.button, .postbit_buttons>a {'+
- 'background: linear-gradient(#d60000, #a70000) !important;'+
- 'border: 1px solid #000000 !important;'+
- 'color: #ffffff !important;'+
- '}'+
- '.spoiler_header:after {'+
- 'background: linear-gradient(#d60000,#a70000) !important;'+
- '}'+
- '.userregistered, .useradvanced {'+
- 'color: #0072bc !important;'+
- '}'+
- '#footer {'+
- 'border-top: 1px solid #000000 !important;'+
- 'background: linear-gradient(#202020,#101010) !important;'+
- '}'+
- '#footer .upper {'+
- 'border: none !important;'+
- 'background: none !important;'+
- '}',
- 'func': function(){
- var x = document.getElementById('overview');
- if(x && unsafeWindow.req){
- var el1 = document.createElement('div');
- el1.style.display = 'none';
- el1.style.className = 'clt-tborder_outer';
- el1.style.marginBottom = '18px';
- x.parentNode.insertBefore(el1,x);
- el1.appendChild(x);
- var otable = document.createElement('table');
- otable.className = 'tborder';
- otable.width = '100%';
- var othead = document.createElement('thead');
- var cookie = unsafeWindow.Cookie.get('collapsed');
- var overviewcollapsed = false;
- if(cookie) overviewcollapsed = cookie.split('|').indexOf('overviewtable') !== -1;
- var otr = document.createElement('tr');
- var otd = document.createElement('td');
- otd.className = 'thead';
- otd.style.width = '65%';
- otd.paddingBottom = '7px';
- var odiv = document.createElement('div');
- var ostrong = document.createElement('strong');
- ostrong.textContent = 'Newest threads';
- odiv.appendChild(ostrong);
- otd.appendChild(odiv);
- otr.appendChild(otd);
- otd = document.createElement('td');
- if(overviewcollapsed){
- otd.className = 'thead thead_collapsed tcat_collapse_collapsed';
- }else{
- otd.className = 'thead';
- }
- otd.paddingBottom = '7px';
- otd.style.width = '35%';
- odiv = document.createElement('div');
- odiv.className = 'expcolimage';
- var oimg = document.createElement('img');
- oimg.id = 'overviewtable_img';
- oimg.className = 'expander';
- if(overviewcollapsed){
- oimg.title = '[+]';
- oimg.alt = '[+]';
- oimg.src = 'http://www.lf-empire.de/forum/images/collapse_collapsed.png';
- }else{
- oimg.title = '[-]';
- oimg.alt = '[-]';
- oimg.src = 'http://www.lf-empire.de/forum/images/collapse.png';
- }
- oimg.style.cursor = 'pointer';
- odiv.appendChild(oimg);
- otd.appendChild(odiv);
- odiv = document.createElement('div');
- ostrong = document.createElement('strong');
- ostrong.textContent = 'Newest posts';
- odiv.appendChild(ostrong);
- otd.appendChild(odiv);
- otr.appendChild(otd);
- othead.appendChild(otr);
- otable.appendChild(othead);
- x.appendChild(otable);
- unsafeWindow.dooverview = exportFunction(function(){
- unsafeWindow.req.open('GET','xmlhttp.php?action=overview');
- unsafeWindow.req.send(null);
- },unsafeWindow);
- unsafeWindow.req.onreadystatechange = exportFunction(function(){
- var req = unsafeWindow.req;
- if(req.readyState === req.DONE){
- var parser = new DOMParser();
- var xml = parser.parseFromString(req.responseText.replace(/<br \/>/gi,''),'application/xml');
- var x = document.getElementById('overview');
- x.parentNode.style.display = 'block';
- if(xml.children.length === 0 || !xml.children[0] || xml.children[0].nodeName === 'parsererror'){
- var el = xml.createElement('pre');
- var y = xml.children[0].children[0];
- el.innerHTML = y.innerHTML;
- xml.children[0].insertBefore(el,y);
- xml.children[0].removeChild(y);
- x.className = 'error';
- x.innerHTML = xml.children[0].innerHTML;
- x.parentNode.className = '';
- return;
- }
- x.parentNode.className = 'clt-tborder_outer';
- var cookie = unsafeWindow.Cookie.get('collapsed');
- var overviewcollapsed = false;
- if(cookie) overviewcollapsed = cookie.split('|').indexOf('overviewtable') !== -1;
- var otable = document.createElement('table');
- otable.className = 'tborder';
- otable.width = '100%';
- var othead = document.createElement('thead');
- var otr = document.createElement('tr');
- var otd = document.createElement('td');
- otd.className = 'thead';
- otd.colSpan = '3';
- otd.style.width = '65%';
- var odiv = document.createElement('div');
- var ostrong = document.createElement('strong');
- ostrong.textContent = 'Newest threads';
- odiv.appendChild(ostrong);
- otd.appendChild(odiv);
- otr.appendChild(otd);
- otd = document.createElement('td');
- if(overviewcollapsed){
- otd.className = 'thead thead_collapsed tcat_collapse_collapsed';
- }else{
- otd.className = 'thead';
- }
- otd.colSpan = '2';
- otd.style.width = '35%';
- odiv = document.createElement('div');
- odiv.className = 'expcolimage';
- var oimg = document.createElement('img');
- oimg.id = 'overviewtable_img';
- oimg.className = 'expander';
- if(overviewcollapsed){
- oimg.title = '[+]';
- oimg.alt = '[+]';
- oimg.src = 'http://www.lf-empire.de/forum/images/collapse_collapsed.png';
- }else{
- oimg.title = '[-]';
- oimg.alt = '[-]';
- oimg.src = 'http://www.lf-empire.de/forum/images/collapse.png';
- }
- oimg.style.cursor = 'pointer';
- oimg.onclick = function(e){
- var element = unsafeWindow.$(e.target);
- //from general.js
- var expandedItem = unsafeWindow.$('#overviewtable_e');
- if(expandedItem.length){
- if(expandedItem.is(':hidden')){// Expanding
- expandedItem.toggle('fast');
- element.attr('src',element.attr('src').replace('collapse_collapsed.png','collapse.png'))
- .attr('alt','[-]')
- .attr('title','[-]');
- element.parent().parent('td').removeClass('tcat_collapse_collapsed');
- element.parent().parent('.thead').removeClass('thead_collapsed');
- unsafeWindow.expandables.saveCollapsed('overviewtable');
- }else{// Collapsing
- expandedItem.toggle('fast');
- element.attr('src',element.attr('src').replace('collapse.png','collapse_collapsed.png'))
- .attr('alt','[+]')
- .attr('title','[+]');
- element.parent().parent('td').addClass('tcat_collapse_collapsed');
- element.parent().parent('.thead').addClass('thead_collapsed');
- unsafeWindow.expandables.saveCollapsed('overviewtable',1);
- }
- }
- return;
- };
- odiv.appendChild(oimg);
- otd.appendChild(odiv);
- odiv = document.createElement('div');
- ostrong = document.createElement('strong');
- ostrong.textContent = 'Newest posts';
- odiv.appendChild(ostrong);
- otd.appendChild(odiv);
- otr.appendChild(otd);
- othead.appendChild(otr);
- otable.appendChild(othead);
- var otbody = document.createElement('tbody');
- otbody.id = 'overviewtable_e';
- if(overviewcollapsed) otbody.style.display = 'none';
- var t1 = xml.children[0].children[1].children[0].children[0].children[0];
- var t2 = xml.children[0].children[1].children[0].children[1].children[0];
- for(var i = 1;i<Math.max(t1.children.length,t2.children.length);++i){
- otr = document.createElement('tr');
- if(i === 1){
- otr.className = 'tcat';
- }else if(i%2 === 0){
- otr.className = 'trow1';
- }else{
- otr.className = 'trow2';
- }
- var html = '';
- if(t1.children[i]){
- html += t1.children[i].innerHTML;
- /*for(var j = 0;j<t1.children[i].children.length;++j){
- var el = t1.children[i].children[j];
- otd = document.createElement('td');
- if(el.attributes['colspan']) otd.colSpan = el.attributes['colspan'].value;
- if(el.attributes['class']) otd.className = el.attributes['class'].value;
- otr.appendChild(otd);
- }*/
- }else html += '<td>/td><td>/td><td>/td>';
- if(t2.children[i]){
- html += t2.children[i].innerHTML;
- /*for(var j = 0;j<t2.children[i].children.length;++j){
- var el = t2.children[i].children[j];
- otd = document.createElement('td');
- if(el.attributes['colspan']) otd.colSpan = el.attributes['colspan'].value;
- if(el.attributes['class']) otd.className = el.attributes['class'].value;
- otr.appendChild(otd);
- }*/
- }else html += '<td>/td><td>/td>';
- otr.innerHTML = html;
- otbody.appendChild(otr);
- }
- otable.appendChild(otbody);
- var y = xml.children[0].children[1];
- t1 = y.children[0].children[0].children[0];
- t2 = y.children[0].children[1].children[0];
- while(x.firstChild) x.removeChild(x.firstChild);
- x.appendChild(otable);
- x.className = '';
- }
- },unsafeWindow.req);
- }
- x = document.querySelectorAll('.tborder');
- for(var i = 0;i<x.length;++i){
- if(x[i].parentNode.id === 'overview') continue;
- var el1 = document.createElement('div');
- for(var j = 0;j<x[i].classList.length;++j){
- el1.classList.add('clt-'+x[i].classList[j]+'_outer');
- }
- if(x[i].classList.contains('clear')) el1.classList.add('clear');
- x[i].parentNode.insertBefore(el1,x[i]);
- el1.appendChild(x[i]);
- }
- x = document.querySelector('#content .wrapper');
- if(x){
- while(x.lastElementChild.nodeName === 'BR') x.removeChild(x.lastElementChild);
- }
- }
- }
- };
- var ct = GM_getValue('customtheme');
- if(!customthemes[ct]) ct = 'none';
- var customtheme = customthemes[ct];
- if(customtheme.css) GM_addStyle(customtheme.css);
- var theme,cts1,cts2,cta;
- GM_registerMenuCommand('Set custom theme',function(){
- if(!theme) return;
- if(cts1 && cts2){
- cts1.style.display = 'block';
- cts2.style.display = 'block';
- return;
- }
- cts1 = document.createElement('div');
- cts1.id = 'cts-closer';
- cts1.addEventListener('click',function(e){
- cts1.style.display = 'none';
- cts2.style.display = 'none';
- },false);
- cts2 = document.createElement('div');
- cts2.id = 'cts-main';
- for(var a in customthemes){
- var x = document.createElement('a');
- x.href = 'javascript:void(0)';
- x.innerHTML = a;
- if(a === ct){
- cta = x;
- x.className = 'selected';
- }
- x.addEventListener('click',function(e){
- e.preventDefault();
- if(e.target === cta) return;
- cta.className = '';
- e.target.className = 'selected';
- cta = e.target;
- GM_setValue('customtheme',e.target.innerHTML);
- },false);
- cts2.appendChild(x);
- }
- document.body.appendChild(cts1);
- document.body.appendChild(cts2);
- });
- function OnLoad(){
- var stylesheets = document.head.querySelectorAll('link[href^="http://www.lf-empire.de/forum/cache/themes/"]');
- var stylenames = [];
- for(var i = 0;i<stylesheets.length;++i){
- stylenames.push(stylesheets[i].href.substr(43,stylesheets[i].href.lastIndexOf('/')-43));
- }
- if(stylenames[0] === 'theme14'){
- theme = 'MyBB Theme';
- }else if(stylenames[0] === 'theme17'){
- theme = 'LFE v3';
- }
- if(!theme) return;
- if(customtheme.func) customtheme.func();
- if(theme == 'MyBB Theme'){
- var x = document.querySelector('#logo img');
- if(x) x.src = 'http://www.lf-empire.de/forum/images/LFEv3/logo.png';
- }else if(theme === 'LFE v3'){
- GM_addStyle('.menu.top_links {'+
- 'margin: -14px 5px -61px 0px !important;'+
- '}'+
- '#panel .lower {'+
- 'box-shadow: none !important;'+
- '}');
- }
- var x = document.querySelector('#panel .lower ul.panel_links a.usercp');
- var y = document.querySelector('#panel .upper a.logout');
- if(x && y){
- x.parentNode.parentNode.parentNode.removeChild(x.parentNode.parentNode);
- y.parentNode.insertBefore(x,y);
- }
- x = document.querySelector('.navigation');
- if(x){
- for(var i = 0;i<x.childNodes.length;++i){
- if(x.childNodes[i].nodeType === x.TEXT_NODE) x.childNodes[i].textContent = x.childNodes[i].textContent.replace(/›/g,'/');
- }
- var y = x.querySelectorAll('br');
- for(var i = 0;i<y.length;++i){
- x.removeChild(y[i]);
- }
- y = x.querySelector('img:last-of-type');
- if(y){
- x.replaceChild(document.createTextNode(' / '),y);
- }
- }
- }
- OnLoad();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement