HG-Optimierung

Vereinfachte Navigation auf Hartgeld.com

当前为 2015-08-24 提交的版本,查看 最新版本

// ==UserScript==
// @name        HG-Optimierung
// @namespace   hgtools
// @include     http://www.hartgeld.com/*
// @version     1.3
// @grant       none
// @description Vereinfachte Navigation auf Hartgeld.com
// ==/UserScript==

(function () {

   var neu = 0;

   $('.tab-content a').each(function() {
     var value = $(this).attr('href');
     $(this).attr('url', value);
     $(this).attr('href', 'javascript:return false;');
   });

   
   $(".tab-content a").click(function() {
      if (neu == 0) {
         $(".container-fluid").css({"position": "relative"});
         $(".container-fluid").prepend('<div id="olframe" style="display:none;height:98%;width:70%;max-width:900px;position:fixed;top:0;right:0;z-index:10000;"><div id="dragbar" style="height:100%;float:left;width:5px;cursor: col-resize;"></div><div style="border: 1px solid #666;opacity: 0.8;float:left;position: absolute;left:5px;background:#fff;border-radius:25px;"><a id="close" style="top: 0px;left: -2px;position: relative;height:20px;width:20px;padding:6px;font-size:30px;display:block;text-decoration:none;" href="javascript:return false;">&#10006;</a></div><iframe id="lesefenster" style="box-shadow: -10px 10px 13px -3px rgba(158,158,158,1);width:98%;height:100%;background:#fff;overflow:auto;border:none;"></iframe></div>');
         $('#olframe').slideDown("normal");
      }

      neu = 1;
      var url = $(this).attr("url");
      
      MarkiertenBereichAufheben();
      jQuery(this).css({"background": "#f6b400", "color": "#333", "font-weight": "bold", "padding": "2px"});
      
      jQuery('#lesefenster').attr("src", url);
   });

   function MarkiertenBereichAufheben() {
      $('.tab-content a').each(function() {
         $(this).css({"background": "none", "color": "#3D728C", "font-weight": "normal", "padding": "0"});
      });
   }

   $(".container-fluid").on('click', '#close', function() {
      $('#lesefenster').slideUp("normal", function(){ $('#olframe').remove();});
      neu = 0;
      MarkiertenBereichAufheben();
   });


   // Breite Overlay ändern
   var i = 0;
   var dragging = false;
   $(".container-fluid").on('mousedown', '#dragbar', function(e) {
      e.preventDefault();

      dragging = true;
      var main = $('#olframe');
      // alert(main.outerWidth());
      var ghostbar = $('<div>',
                     {id:'ghostbar',
                         css: {
                              background: '#999',
                              width: '2px',
                              position: 'absolute',
                              cursor: 'col-resize',
                              zIndex: '10001',
                              height: main.outerHeight(),
                              top: main.offset().top,
                              left: main.offset().left
                              }
                        }).appendTo('body');
      $('#olframe').hide();
      
      $(document).mousemove(function(e) {
         ghostbar.css("left",e.pageX+2);
      });
   });

   $(document).mouseup(function(e) {
      if (dragging) {
         $('#olframe').show();
         $('#olframe').css("left", e.pageX+2);
         $('#olframe').css("width", $(document).width() - e.pageX+2);
         $('#ghostbar').remove();
         $(document).unbind('mousemove');
         dragging = false;
      }
    });
   
   
   // Inhaltsseite
   if (self !== top) {
      jQuery('.header-fixed').css({"display": "none"});
      jQuery('#top').css({"display": "none"});
      jQuery('#top2').css({"display": "none"});
      jQuery('#main').css({"margin-top": "10px"});
      
      var mtext = '';
      
      $(".artikel").prepend('<div style="display:none;box-shadow: -10px 10px 13px -3px rgba(158,158,158,1); border-radius:8px;position: absolute; text-align: center; padding: 5px 10px 10px; width: 200px; background: #f6b400; color: #333; font-weight: bold;" id="message"><a id="mailsenden" href="javascript:return false;">Neuen Kommentar zu diesem Zitat einsenden&nbsp;&raquo;</a></div>');
      
      $('.artikel').mouseup(function(event) {
         var temp = document.getSelection().toString();
         if (temp != '') {
            mtext = temp;
            $("#message").css({
               top: event.pageY,
               left: event.pageX
            }).slideDown("normal");
         }
      });

      $(".artikel").mousedown(function(event) {
         if (event.target.id == 'mailsenden') {
            var seite = window.location.href.split('/');
            mtext = Textkuerzen(mtext);
            window.location.href = "mailto:[email protected]?subject=Neuer Leserkommentar zu Seite " + seite[3] + "&body=Sehr geehrtes Hartgeld-Team,%0A%0Azu folgendem Eintrag auf der Seite " + seite[3] + " möchte ich gerne wie untenstehend kommentieren:%0A%0AIhr Eintrag:%0A------------------------------------------------------------%0A" + encodeURIComponent(mtext) + "%0A------------------------------------------------------------%0A%0AMein Kommentar dazu:%0A%0A";
         }
         SchliessePopup();
      });
      
      function SchliessePopup() {
         $('#message').slideUp("normal");

         if (window.getSelection) {
            window.getSelection().removeAllRanges();
         } else if (document.selection) {
            document.selection.empty();
         }
      }
      
      function Textkuerzen(text) {
         if (text.length > 300) {
            var trimmedString = text.substr(0, 300);
            trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")));
            return trimmedString + ' [...]';
         }
      }
   }
   
}());