// ==UserScript==
// @name HG-Optimierung
// @namespace hgtools
// @include http://www.hartgeld.com/*
// @version 1.6
// @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:100%;width:' + Fenstergroesse() + ';position:fixed;top:0;right:0;z-index:10000;"><div id="dragbar" style="position: absolute;left: -2px;height:100%;width:10px;cursor: col-resize;"></div><div style="border: 1px solid #666;opacity: 0.8;float:left;position: absolute;left:-33px;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;">✖</a></div><iframe id="lesefenster" style="box-shadow: -10px 10px 13px -3px rgba(158,158,158,1);width:100%;height:100%;background:#fff;overflow:auto;border:none;"></iframe></div>');
$('#olframe').slideDown("normal");
}
neu = 1;
var url = $(this).attr("url");
MarkiertenBereichAufheben();
$(this).css({"background": "#f6b400", "color": "#333", "font-weight": "bold", "padding": "2px"});
$('#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
$(".container-fluid").on('mouseover', '#dragbar', function() {
$("#dragbar").css({"border-left": "3px dashed #666"});
});
$(".container-fluid").on('mouseout', '#dragbar', function() {
$("#dragbar").css({"border-left": "none"});
});
var i = 0;
var dragging = false;
$(window).on('mousedown', '#dragbar', function(e) {
e.preventDefault();
dragging = true;
var main = $('#olframe');
var ghostbar = $('<div>',
{ id:'ghostbar', css:
{
borderLeftWidth: '3px',
borderLeftColor: '#666',
borderLeftStyle: 'dashed',
position: 'absolute',
cursor: 'col-resize',
zIndex: '10001',
height: main.outerHeight(),
top: main.offset().top,
left: main.offset().left-2
}
}).appendTo('body');
$('#lesefenster').css({"pointer-events": "none"});
$(document).mousemove(function(e) {
ghostbar.css("left", e.pageX);
$('#olframe').css(
{ "left": e.pageX+2,
"width": $(document).width() - e.pageX
});
});
});
$(document).mouseup(function(e) {
if (dragging) {
// $('#olframe').css(
// { "left": e.pageX,
// "width": $(document).width() - e.pageX
// });
$('#lesefenster').css({"pointer-events": "initial"});
$('#ghostbar').remove();
$(document).unbind('mousemove');
dragging = false;
}
});
$(window).on('resize', function(event) {
$("#olframe").css({"width": Fenstergroesse(), "right": "0", "left": "unset"});
});
function Fenstergroesse() {
var breite = '70%';
if ($(window).width() > 1300) {
breite = '50%';
}
return breite;
}
///////////////////////////////////////////////////////////////////////////////////
// Inhaltsseite
if (self !== top) {
// CSS
var cssstring = (function () {/*
<style>
.header-fixed,
.werbebox3 p {
display: none;
}
.bodyText_fett,
.bodyText strong {
font-size: 14px;
}
#main {
margin-top: 10px;
}
.bodyText_fett_blau {
display: inline !important;
background: #44e;
color: #fff;
}
.bodyText_fett_blau::after,
.bodyText_fett_blau::before {
content: '\00a0';
line-height: 25px;
}
</style>
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];
$('head').append(cssstring);
var mtext = '';
// Mailoverlay
$(".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 »</a></div>');
// URLoverlay
$(".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: 3px 10px 3px; background: #f6b400; color: #333; font-weight: bold;" id="linkdomain"></div>');
// Mailzitat
$('.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 + ' [...]';
} else {
return text;
}
}
// URL Hover
$(".artikel a").hover(
function() {
clearTimeout($(this).data('timeout'));
var ax = document.createElement('a');
ax.href = $(this).attr('href');
$('#linkdomain').text(ax.hostname);
var position = $(this).position();
$("#linkdomain").css({
top: position.top-30,
left: position.left
}).show();
},
function() {
var t = setTimeout(function() {
$('#linkdomain').hide();
}, 1000);
$(this).data('timeout', t);
}
);
}
}());