Created
February 9, 2010 06:32
-
-
Save wittman/298967 to your computer and use it in GitHub Desktop.
pipioCustomize - BACKGROUND DESIGN: Nature scene background elements removed, light background inserted. SCROLL TALL POSTS OF ANY CONTENT TYPE added to whitespace module. Posts >= 250px in height get overflow set to scroll. Firefox/Greasemonkey and Safari
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 pipioCustomize | |
// @namespace http://wittman.org/projects/pipiocustomize/ | |
// @description Customization for pip.io | |
// @author Micah Wittman | |
// @include http://pip.io/* | |
// @include https://pip.io/* | |
// @version 0.1.7 | |
// ==/UserScript== | |
/* | |
Author: Micah Wittman | http://wittman.org/ | http://wittman.org/projects/pipiocustomize/ | http://pip.io/micah | |
Versions: | |
* 2010-04-01 - version 0.1.7 - INLINE IMAGE module removed - obsolete since native thumbnail feature added. SCROLL TALL POSTS OF ANY CONTENT TYPE added to whitespace module. Posts >= 250px in height get overflow set to scroll. | |
* 2010-04-01 - version 0.1.6 - TRIM EXCESSIVE LINBREAKS: Repeated line breaks get collapsed to maximum of <br><br> instances. Getting your stream obscrued by posts that stretch long distance down the page because of a whole stack of repeated line returns. | |
* 2010-02-10 - version 0.1.5 - INLINE IMAGES: Image attachments displayed inline.BACKGROUND DESIGN: Nature scene background elements removed, light background inserted. Firefox/Greasemonkey and Safari/Greasekit compatible (does not yet work on Chrome, unfortunately). | |
* 2010-02-08 - version 0.1.0 - Nature scene background elements removed, dark gray background inserted. | |
*/ | |
(function(){ | |
/************************ Style Initialization ********************/ | |
//BACKGROUND DESIGN | |
var css = "@namespace url(http://www.w3.org/1999/xhtml); #background, .ground, .ground_img, .celestial, .stars, .cloud, .sky, .celestial, .moon{background-image:none !important} #background{background:none repeat scroll 0 0 rgb(240,240,240) !important}"; | |
if (typeof GM_addStyle != "undefined") { | |
GM_addStyle(css); | |
} else if (typeof addStyle != "undefined") { | |
addStyle(css); | |
} else { | |
var heads = document.getElementsByTagName("head"); | |
if (heads.length > 0) { | |
var node = document.createElement("style"); | |
node.type = "text/css"; | |
node.appendChild(document.createTextNode(css)); | |
heads[0].appendChild(node); | |
} | |
} | |
/************************ Global Variables ***********************/ | |
var $jq = null; | |
/************************ Main Initialization ********************/ | |
//LOAD JQUERY | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js'; | |
GM_JQ.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(GM_JQ); | |
// Check if jQuery's loaded | |
function GM_wait() { | |
//unsafeWindow detection | |
if(typeof unsafeWindow != 'undefined') | |
{ | |
if(typeof unsafeWindow.jQuery != 'undefined') | |
{ | |
jQuery = unsafeWindow.jQuery; | |
} | |
} | |
if(typeof jQuery == 'undefined') { | |
window.setTimeout(GM_wait,100); | |
}else{ | |
$jq = jQuery.noConflict(true); | |
run_all(); | |
} | |
} | |
/************************ Helper Functions ********************/ | |
function run_all_wait() | |
{ | |
if($jq != null){ | |
window.setTimeout(run_all, 501); | |
} | |
} | |
/***************** Main Processing Functions ******************/ | |
function run_all(){ | |
//Modules | |
collapse_tall_posts(); | |
//Restart | |
run_all_wait(); | |
} | |
//TRIM EXCESSIVE LINBREAKS AND SCROLL TALL POSTS OF ANY CONTENT TYPE | |
function collapse_tall_posts() { | |
var post_body = $jq('#content_wrapper div.post div.header span.user_action'); | |
post_body.each(function(){ | |
var body = $jq(this); | |
var bodyContainer = body.siblings(':last'); | |
if(!bodyContainer.hasClass('pipiocustomize_proc_collapse_tall_posts')){ | |
//bodyContainer.css('background-color','red'); | |
var htmlOld = bodyContainer.html(); | |
var htmlNew = htmlOld.replace(/(<br><br>\s*)+/g, '<br> <br>'); | |
bodyContainer.html(htmlNew); | |
var post = bodyContainer.parent().parent(); | |
var heightStr = post.css('height'); | |
var height = parseInt(heightStr.replace('px','')); | |
if(height >= 225){ | |
post.css({'overflow':'scroll','max-height':'200px','overflow-x':'hidden'}); | |
} | |
bodyContainer.addClass('pipiocustomize_proc_collapse_tall_posts'); | |
} | |
}); | |
} | |
/************************************************************* | |
************************** RUN MAIN FUNCTIONS ************************ | |
******************** *********************/ | |
if(window.location.href.indexOf('pip.io/') > -1) //greasekit doesn't support @include directs, so test URL for context | |
{ | |
GM_wait(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment