Advertisement
Guest User

Untitled

a guest
Oct 1st, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Breadfish Customizer
  3. // @namespace   BauerProductions
  4. // @include     http://breadfish.de*
  5. // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
  6. // @version     1
  7. // @grant       GM_xmlhttpRequest
  8. // ==/UserScript==
  9.  
  10. var username = null;
  11.  
  12. var settings = new Array();
  13.  
  14. function SaveSettings(identificator, property, value){
  15.     if(value[0] == "#") value = value.slice(1, value.length);
  16.    
  17.     var data = new Array();
  18.     var tmp = [identificator, property, value];
  19.    
  20.     data.push(tmp);
  21.     data = JSON.stringify(data);
  22.    
  23.     GM_xmlhttpRequest({
  24.         method: "GET",
  25.         url: "http://jack.city-of-sa.de/BreadfishCustomizer/setsettings.php?username=" + username + "&data=" + data,
  26.         onload: function(response){
  27.             // alert(response.responseText);
  28.         }
  29.     });
  30. }
  31.  
  32. function GetSettings(object, name, value){
  33.     GM_xmlhttpRequest({
  34.         method: "GET",
  35.         url: "http://jack.city-of-sa.de/BreadfishCustomizer/getsettings.php?username=" + username,
  36.         onload: function(response){
  37.             settings = JSON.parse(response.responseText);
  38.            
  39.             for(var i=0; i<settings.length; i++){
  40.                 $(settings[i]["identificator"]).css(settings[i]["property"], "#" + settings[i]["value"]);
  41.             }
  42.         }
  43.     });
  44. }
  45.  
  46. $(document).ready(function(){
  47.     if($("#userMenu a span").length == 0){
  48.         return 0;
  49.     }
  50.    
  51.     username = $("#userMenu a span").html()
  52.    
  53.     GetSettings();
  54.    
  55.     $("#footerNavigation .navigationItems").append("<li class=\"styleChooser\"><a id=\"breadfishCustomizerSettingsLink\">Breadfish Customizer</a></li>");
  56.    
  57.     $("#breadfishCustomizerSettingsLink").click(function(){
  58.         var greyedBackground = document.createElement("div");
  59.         greyedBackground.style.position = "fixed";
  60.         greyedBackground.style.zIndex = "999";
  61.         greyedBackground.style.left = "0px";
  62.         greyedBackground.style.top = "0px";
  63.         greyedBackground.style.right = "0px";
  64.         greyedBackground.style.bottom = "0px";
  65.         greyedBackground.style.backgroundColor = "rgba(190, 190, 190, 0.60)";
  66.         $(document).keyup(function(event){
  67.             if(event.which == 27){
  68.                 $(greyedBackground).animate({opacity: "0"}, "slow", function(){
  69.                     $(greyedBackground).remove();
  70.                     $(document).unbind("keyup");
  71.                 });
  72.             }
  73.         });
  74.        
  75.         var settingsContainerTitle = document.createElement("div");
  76.         settingsContainerTitle.style.position = "absolute";
  77.         settingsContainerTitle.style.left = "0px";
  78.         settingsContainerTitle.style.right = "0px";
  79.         settingsContainerTitle.style.height = "50px";
  80.         settingsContainerTitle.style.width = "100%";
  81.         settingsContainerTitle.style.color = "white";
  82.         settingsContainerTitle.style.backgroundColor = "#2A3441";
  83.         settingsContainerTitle.innerHTML = "Breadfish Customizer - Einstellungen";
  84.         settingsContainerTitle.style.fontSize = "20px";
  85.         settingsContainerTitle.style.textAlign = "center";
  86.        
  87.         var settingsContainer = document.createElement("div");
  88.         settingsContainer.style.position = "fixed";
  89.         settingsContainer.style.width = "800px";
  90.         settingsContainer.style.minHeight = "300px";
  91.         settingsContainer.style.left = "50%";
  92.         settingsContainer.style.top = "0px";
  93.         settingsContainer.style.marginLeft = "-400px";
  94.         settingsContainer.style.backgroundColor = "white";
  95.         settingsContainer.style.paddingLeft = "20px";
  96.         settingsContainer.style.paddingRight = "20px";
  97.         settingsContainer.style.paddingBottom = "20px";
  98.         settingsContainer.style.borderBottomLeftRadius = "20px";
  99.         settingsContainer.style.borderBottomRightRadius = "20px";
  100.        
  101.         var settingsContainerOptionsContainer = document.createElement("span");
  102.         settingsContainerOptionsContainer.style.marginTop = "50px";
  103.         settingsContainerOptionsContainer.style.display = "block";
  104.        
  105.         $(settingsContainer).append(settingsContainerTitle);
  106.         $(settingsContainer).append(settingsContainerOptionsContainer);
  107.         $(greyedBackground).append(settingsContainer);
  108.        
  109.         var options = [
  110.             ["-topMenu", "bc-menue-color", "Farbe des obersten Menüs", "background-color"],
  111.             ["-content", "bc-content-color", "Farbe des Kontentbereiches", "background-color"],
  112.             ["body", "bc-page-background-color", "Farbe des Seitenhintergrundes", "background-color"],
  113.             ["-search form input", "bc-search-back-color", "Farbe der Suchmaske (Hintergrund)", "background-color"],
  114.             ["-search form input", "bc-search-fore-color", "Farbe der Suchmaske (Vordergrund)", "color"],
  115.             [".sidebar", "bc-sidebar-back-color", "Farbe des Seitenmenüs (Sidebar)", "background-color"],
  116.             [".containerHeadline h3 a", "bc-forum-overview-link-fore-color", "Farbe der Forenlinks (Startseite)", "color"],
  117.         ];
  118.         for(var i=0; i<options.length; i++){
  119.             if(options[i][0][0] == "-"){
  120.                 var tmpElementID = "#" + options[i][0].slice(1, options[i][0].length);
  121.             }else{
  122.                 var tmpElementID = options[i][0];
  123.             }
  124.            
  125.             var settingsOption = document.createElement("span");
  126.             settingsOption.style.float = "left";
  127.             settingsOption.style.marginRight = "20px";
  128.             settingsOption.style.marginTop = "20px";
  129.             settingsOption.innerHTML = "<a title='Halten, um zu identifizieren' onmousedown='$(\"" + tmpElementID + "\").css(\"border\", \"1px solid red\");' onmouseup='$(\"" + tmpElementID + "\").css(\"border\", \"0px\");'>" + options[i][2] + "</a>: <br /><input type='color' id='" + options[i][1] + "' />";
  130.            
  131.             settingsOption.onchange = (function(i, tmpElementID){return function(){
  132.                 SaveSettings(options[i][0], options[i][3], $("#" + options[i][1]).val());
  133.                
  134.                 $(tmpElementID).css(options[i][3], $("#" + options[i][1]).val());
  135.                
  136.                 $("html, body").animate({scrollTop: ($(tmpElementID).offset().top)}, 'fast', function(){
  137.                     $(settingsContainer).animate({ opacity: 0.3}, 'fast');
  138.                     setTimeout(function(){
  139.                         $(window).scroll(function(){
  140.                             $(settingsContainer).animate({ opacity: 1.0}, 'fast');
  141.                             $(window).unbind("scroll");
  142.                             $(window).unbind("click");
  143.                         });
  144.                        
  145.                         $(window).click(function(){
  146.                             $(settingsContainer).animate({ opacity: 1.0}, 'fast');
  147.                             $(window).unbind("scroll");
  148.                             $(window).unbind("click");
  149.                         });
  150.                     }, 1000);
  151.                 });
  152.             };})(i, tmpElementID);
  153.             $(settingsContainerOptionsContainer).append(settingsOption);
  154.         }
  155.         $(settingsContainerOptionsContainer).append("<span style='clear: both;'></span>");
  156.         $("body").append(greyedBackground);
  157.     });
  158.    
  159.  
  160. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement