// ==UserScript==
// @version 0.1
// @name eUSA Forums Feed for Erepublik
// @namespace http://eusaforums.com/
// @description Preview the latest posts on your favorite eUSA Forums board from the Erepublik homepage
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @match *://www.erepublik.com/*
// @exclude *://www.erepublik.com/*/*
// @copyright 2014+, Mike Ontry
// @downloadURL none
// ==/UserScript==
jQuery("body").append ( ' \
\
' );
jQuery("#eUSAForums-submit").click ( function () {
var user = jQuery("#eUSAForums-user").val ();
var pass = jQuery("#eUSAForums-pass").val ();
var board = jQuery("#eUSAForums-board").val ();
var posts = jQuery("#eUSAForums-posts").val ();
if (GM_getValue("user") != user || GM_getValue("pass") != pass || GM_getValue("board") != board || GM_getValue("posts") != posts ) {
GM_setValue("user", user);
GM_setValue("pass", pass);
GM_setValue("board", board);
GM_setValue("posts", posts);
jQuery("#gmPopupContainer").hide ();
jQuery("#eUSAForums-container").find("ul").empty();
waitForFeed();
}else {
jQuery("#gmPopupContainer").hide ();
}
} );
jQuery("#gmCloseDlgBtn").click ( function () {
jQuery("#gmPopupContainer").hide ();
} );
jQuery(".column:first").append('Feed Settings
');
jQuery(".column:first").append('');
jQuery("#gmPopupContainer").css({top: jQuery("#eUSAForums-config").offset().top, left: jQuery("#eUSAForums-config").offset().left});
jQuery("#eUSAForums-config").click ( function () {
jQuery("#gmPopupContainer").show ();
});
jQuery(document).on("mouseleave mouseenter", "li.eUSAForums-list", function (e) {
if (e.type === 'mouseenter') {
jQuery(this).children('.eUSAForums-items').css('display', 'none');
jQuery(this).children('.eUSAForums-desc').css('display', 'inline-block');
jQuery(this).height(140);
jQuery(this).children('.eUSAForums-desc').height(140);
}
else{
jQuery(this).children('.eUSAForums-items').css('display', 'block');
jQuery(this).children('.eUSAForums-desc').css('display', 'none');
jQuery(this).height(70);
jQuery(this).children('.eUSAForums-desc').height(70);
}
});
function waitForFeed() {
jQuery(document).ready(function()
{
jQuery.get('http://ereptools.tk/feeds/eusa.php?b='+GM_getValue("board", "")+'&u='+GM_getValue("user")+'&p='+GM_getValue("pass")+'&l='+GM_getValue("posts", "5"), function (data) {
jQuery(data).find("feed").each(function () {
var el = jQuery(this);
var title = el.find("title:first").text();
jQuery(".eUSAForums-title").html(title);
});
jQuery(data).find("entry").each(function () {
var el = jQuery(this);
var title = el.find("title").text();
var link = el.find("id").text();
var pubDate = el.find("published").text();
var desc = el.find("summary").text();
var author = el.find("author").find("name").text();
var authorLink = el.find("author").find("uri").text();
jQuery("#eUSAForums-container").find("ul").append('
');
});
});
});
}
//CSS
GM_addStyle ( " \
#gmPopupContainer { \
position: absolute; \
width: 278px; \
padding: 2em; \
background: #C1E4F1; \
border: 3px double black; \
border-radius: 1ex; \
z-index: 999; \
display: none; \
} \
#gmPopupContainer button{ \
cursor: pointer; \
margin: 1em 1em 0; \
border: 1px outset buttonface; \
} \
#gmCloseDlgBtn { \
cursor: pointer; \
position: absolute; \
top: 0px; \
right: 0px; \
} \
#eUSAForums-config { \
background-color: #C1E4F1; \
text-align: center; \
cursor: pointer; \
} \
.eUSAForums-items a { \
float: left; \
color: #333; \
line-height: 15px; \
clear: both; \
font-size: 14px; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums li { \
width: 318px; \
height: 70px; \
top: 0; \
left: 0; \
padding: 7px; \
float: left; \
clear: both; \
border-bottom: 1px solid #efeded; \
position: relative; \
} \
.eUSAForums ul { \
list-style-type: none; \
} \
.visit_eUSAForums { \
float: left; \
width: 100px; \
height: 20px; \
-moz-border-radius-topleft: 5px; \
-moz-border-radius-topright: 5px; \
border-radius: 5px 5px 0 0; \
background-color: #e0ddd0; \
background-image: -webkit-linear-gradient(#f2f0ec 0,#e0ddd0 100%); \
background-image: linear-gradient(#f2f0ec 0,#e0ddd0 100%); \
box-shadow: #d6d1c5 0 1px 2px inset; \
position: absolute; \
bottom: 3px; \
font-size: 11px; \
text-shadow: #fff 0 1px 0; \
color: #726c5f; \
left: 116px; \
text-align: center; \
line-height: 22px; \
} \
.eUSAForums-desc { \
background-color: #E7EAEF; \
display: none; \
z-index: 10; \
width: 318px; \
height: 70px; \
position: absolute; \
top: 0; \
left: 0; \
padding: 7px; \
overflow-y: auto; \
overflow-x: auto; \
color: #333; \
line-height: 15px; \
clear: both; \
font-size: 14px; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc a { \
color: #346; \
text-decoration: underline; \
line-height: 15px; \
clear: both; \
font-size: 14px; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc .bbc_standard_quote { \
background-color: #D7DAEC; \
border-bottom-style: solid; \
border-bottom-color: #9999AA; \
padding: 3px; \
font-size: small; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc .bbc_alternate_quote { \
background-color: #E7EAFC; \
border-bottom-style: solid; \
border-bottom-color: #9999AA; \
border-top-style: solid; \
border-top-color: #9999AA; \
padding: 3px; \
font-size: small; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc .topslice_quote { \
background-color: #D7DAEC; \
border-top-style: solid; \
border-top-color: #9999AA; \
padding: 3px; \
font-size: small; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc .topslice_quote a { \
font-size: x-small; \
font-family: Cambria,Georgia,serif; \
} \
.eUSAForums-desc .bbc_img { \
max-width: 300px; \
max-height: 400px; \
} \
.youtube iframe { \
width: 275px; \
height: 140px; \
} \
" );
window.addEventListener('load', waitForFeed(), false);