-
-
Save fizerkhan/8eca9970a9494a3d32719bf824faa0f0 to your computer and use it in GitHub Desktop.
Centers the new slider on Feedly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Feedly Centered Slider | |
// @namespace http://salvatorelab.es | |
// @version 2.0 | |
// @description Centers the slider on Feedly | |
// @match http://feedly.com/* | |
// @grant GM_addStyle | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | |
// ==/UserScript== | |
function centerContentAndArrows() { | |
var floatingContent = document.getElementsByClassName('floatingEntryContent')[0]; | |
if (floatingContent !== undefined) { | |
var contentWidth = floatingContent.offsetWidth; | |
floatingContent.style = "right: calc(50% - " + (contentWidth/2) + "px) !important;"; | |
var side = ($( window ).width() - contentWidth)/2 + 25; | |
GM_addStyle(".slideBumper-right {right: "+side+"px;}"); | |
GM_addStyle(".slideBumper-left {left: "+side+"px;}"); | |
} | |
} | |
function centerHeader() { | |
var floatingContent = document.getElementsByClassName('floatingEntryContent')[0]; | |
if (floatingContent !== undefined) { | |
var contentWidth = floatingContent.offsetWidth; | |
floatingContent.style = "right: calc(50% - " + (contentWidth/2) + "px) !important;"; | |
var header = $('.floatingEntryContentSlide .shareBarFixedHolder .headerInfo'); | |
header.css('right', '50%').css('right', '-=' + (contentWidth/2) + 'px'); | |
} | |
} | |
//arrows | |
GM_addStyle(".bumperHolder {position: relative !important;"); | |
GM_addStyle(".slideBumper-right {position: fixed !important; right: 0px; left: auto !important;}"); | |
GM_addStyle(".slideBumper-left {position: fixed !important; left: 0px; right: auto !important;}"); | |
window.onresize = function() { | |
centerContentAndArrows(); | |
centerHeader(); | |
}; | |
var insertedNodes = []; | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
for(var i = 0; i < mutation.addedNodes.length; i++) { | |
if (mutation.addedNodes[i].classList.contains('floatingEntryContent')) { | |
centerContentAndArrows(); | |
} | |
if (mutation.target.classList.contains('headerInfo')) { | |
centerHeader(); | |
} | |
} | |
}); | |
}); | |
observer.observe(document, { | |
childList: true, | |
subtree: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment