Permalink
Browse files

first version (1.0.0) of tinted sheen blocker.

  • Loading branch information...
0 parents commit b442ca22bd59f6167d873d89f830f8369b494ec1 @gleuch committed Mar 8, 2011
@@ -0,0 +1,5 @@
+.DS_Store
+._*
+safari.*
+*.pem
+versions
@@ -0,0 +1,31 @@
+h1. Tinted Sheen
+
+Firefox Add-on, Chrome Extension, and inline code to cure that #winning Charlie Sheen hangover.
+
+by Greg Leuch ("@gleuch":http://twitter.com/gleuch | "http://gleuch.com":http://gleuch.com)
+
+
+h2. Install
+
+Current version is at *1.0.0*.
+
+ * "Firefox 1.0.0 download":http://addons.gleuch.com/tinted-sheen/downloads/firefox
+ * "Chrome 1.0.0 download":http://addons.gleuch.com/tinted-sheen/downloads/chrome
+
+
+h2. Credits
+
+Based on the "Shaved Bieber":http://github.com/gleuch/shaved-bieber and "Ctrl+F'd":http://github.com/gleuch/ctrl-f-d projects by "Greg Leuch":http://www.gleuch.com.
+Special thanks to "Chris Menning":http://twitter.com/straythenomad" and the FAT Lab crew":http://fffff.at!
+
+
+h2. License
+
+MIT License "http://creativecommons.org/licenses/MIT":http://creativecommons.org/licenses/MIT. Not for commercial use.
+
+
+h2. Changelog
+
+h4. 1.0.0 (8 Mar 2011)
+
+Created from "Shaved Bieber":http://fffff.at/shaved-bieber project, tested, released on "FAT Lab":http://fffff.at/tinted-sheen for Firefox & Chrome.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,21 @@
+{
+ "background_page": "tinted-sheen.html",
+ "content_scripts": [ {
+ "all_frames": true,
+ "js": [ "jquery-latest.js" ],
+ "matches": [ "http://*/*" ],
+ "run_at": "document_start"
+ } ],
+ "description": "The cure for your #winning Charlie Sheen hangover.",
+ "icons": {
+ "16": "tinted-sheen16.png",
+ "32": "tinted-sheen32.png",
+ "48": "tinted-sheen48.png",
+ "64": "tinted-sheen64.png",
+ "128": "tinted-sheen128.png"
+ },
+ "name": "Tinted Sheen Blocker",
+ "permissions": [ "tabs", "http://*/*" ],
+ "update_url": "http://addons.gleuch.com/tinted-sheen/updates/chrome?data=",
+ "version": "1.0.0"
+}
@@ -0,0 +1,21 @@
+<html><head>
+<script>
+
+function selectedTab(tab) {
+ var detailsObj = new Object();
+ detailsObj.file = "tinted-sheen.js";
+ chrome.tabs.executeScript(tab.id, detailsObj, function(){});
+}
+
+function onUpdatedTab(tabid, objectinfo, tab) {
+ var targettab = tab;
+ // if (tab.url.indexOf("facebook") > -1) return;
+ setTimeout(function() { selectedTab(tab);}, 1000);
+}
+
+function pageOnClicked(tab) {}
+
+chrome.tabs.onUpdated.addListener(onUpdatedTab);
+
+</script>
+</head><body></body></html>
@@ -0,0 +1,114 @@
+/*
+ TINTED SHEEN
+ Bookmarklet, & browser extensions to cure that winning Charlie Sheen hangover.
+
+ by Greg Leuch <http://gleuch.com> / @gleuch
+
+ MIT License - http://creativecommons.org/licenses/MIT
+
+ ------------------------------------------------------------------------------------
+
+*/
+
+
+Array.prototype.in_array = function(p_val, sensitive) {for(var i = 0, l = this.length; i < l; i++) {if ((sensitive && this[i] == p_val) || (!sensitive && this[i].toLowerCase() == p_val.toLowerCase())) {return true;}} return false;};
+function rgb2hex(rgb) {rgb = rgb.replace(/\s/g, "").replace(/^(rgb\()(\d+),(\d+),(\d+)(\))$/, "$2|$3|$4").split("|"); return "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);}
+function hex(x) {var hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F"); return isNaN(x) ? "00" : hexDigits[(x-x%16)/16] + hexDigits[x%16];}
+
+
+Array.prototype.in_array = function(p_val, sensitive) {for(var i = 0, l = this.length; i < l; i++) {if ((sensitive && this[i] == p_val) || (!sensitive && this[i].toLowerCase() == p_val.toLowerCase())) {return true;}} return false;};
+function rgb2hex(rgb) {rgb = rgb.replace(/\s/g, "").replace(/^(rgb\()(\d+),(\d+),(\d+)(\))$/, "$2|$3|$4").split("|"); return "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);}
+function hex(x) {var hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F"); return isNaN(x) ? "00" : hexDigits[(x-x%16)/16] + hexDigits[x%16];}
+
+
+function tinted_sheen_start($_) {
+ $_.fn.reverse = function(){return this.pushStack(this.get().reverse(), arguments);};
+
+ (function($_) {
+ $_.tinted_sheen = function(data, c) {
+ if (!$_.tinted_sheen.settings.finish) $_.tinted_sheen.init();
+ $_(data).tinted_sheen(c);
+ if (!$_.tinted_sheen.settings.finish) $_.tinted_sheen.finish();
+ };
+
+ $_.fn.tinted_sheen = function(c) {
+ return this.filter(function() {return $_.tinted_sheen.filter(this);}).each(function() {$_.tinted_sheen.tint(this, c);});
+ };
+
+ $_.extend($_.tinted_sheen, {
+ settings : {hide_bg : true, search: /(charlie(\s|\-|\_)?)?(sheen|porn\sfamily|\#winning|\#tigerblood)/img, replace: '<span class="tinted_sheen" style="color: %C; background-color: %C;">$1$2$3$4$5</span>', starred: '****** ******', init : false, finish : false},
+
+ pluck : function(str) {return str.replace(/(charlie\s)(sheen)/img, '****** ******').replace(/(sheen|\#winning)/img, '******');},
+
+ filter : function(self) {
+ if (self.nodeType == 1) {
+ var tag = self.tagName.toLowerCase();
+ return !(self.className.match('tinted_sheen') || tag == 'head' || tag == 'img' || tag == 'textarea' || tag == 'option' || tag == 'style' || tag == 'script');
+ } else {
+ return true;
+ }
+ },
+
+ tint : function(self, c) {
+ $_(self).css({'text-shadow' : 'none'});
+
+ if (self.nodeType == 3) {
+ if (self.nodeValue.replace(/\s/ig, '') != '') {
+ if (!c) c = $_(self).parent() ? $_(self).parent().css('color') : '#000000';
+ text = self.nodeValue.replace($_.tinted_sheen.settings.search, $_.tinted_sheen.settings.replace.replace(/\%C/mg, c) );
+ $_(self).after(text);
+ self.nodeValue = '';
+ }
+ } else if (self.nodeType == 1) {
+ c = rgb2hex($_(self).css('color'));
+ if ($_(self).children().length > 0) {
+ $_.tinted_sheen($_(self).contents(), c);
+ } else if ($_(self).children().length == 0) {
+ text = $_(self).html().replace($_.tinted_sheen.settings.search, $_.tinted_sheen.settings.replace.replace(/\%C/mg, c) );
+ $_(self).html(text);
+ }
+ }
+ },
+
+ init : function() {
+ $_.tinted_sheen.settings.init = true;
+ },
+
+ finish : function() {
+ $_(document).each(function() {this.title = $_.tinted_sheen.pluck(this.title);});
+
+ $_('img, input[type=image]').each(function() {
+ if ($_(this).attr('alt').match($_.tinted_sheen.settings.search) || $_(this).attr('title').match($_.tinted_sheen.settings.search) || $_(this).attr('src').match($_.tinted_sheen.settings.search)) {
+ var r = $_(this), w = r.width(), h = r.height(), c = rgb2hex($_(this).css('color'));
+ r.css({background: c, width: r.width(), height: r.height()}).attr('src', 'http://assets.gleuch.com/blank.png').width(w).height(h);
+ }
+ });
+
+ $_('input[type=text]').each(function() {if ($_(this).val().match($_.tinted_sheen.settings.search) ) $_(this).val( $_.tinted_sheen.pluck($_(this).val()) );});
+ $_('textarea, option').each(function() {if ($_(this).html().match($_.tinted_sheen.settings.search) ) $_(this).html( $_.tinted_sheen.pluck($_(this).html()) );});
+
+ var s = document.createElement("style");
+ s.innerHTML = ".tinted_sheen {font-size: inherit !important; "+ ($_.tinted_sheen.settings.hide_bg ? "background-image: none !important;" : "") +"} .bg_tinted_sheen {"+ ($_.tinted_sheen.settings.hide_bg ? "background-image: none !important;" : "") +"}";
+ $_('head').append(s);
+
+ $_.tinted_sheen.settings.finish = true;
+ }
+ });
+ })($_);
+
+ $_.tinted_sheen('body', '#000000');
+}
+
+
+
+
+
+
+/* Let start blocking the #winning */
+try {
+ if (!jQuery('body').hasClass('tigerblood')) {
+ jQuery('body').addClass('tigerblood');
+ tinted_sheen_start(jQuery);
+ }
+} catch(err) {
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,39 @@
+<html>
+<head>
+<!--
+
+ TINTED SHEEN
+ Bookmarklet, Firefox extension, and inline code to clean up those lower regions of websites from Sheen mentions.
+
+ by Greg Leuch <http://www.gleuch.com>
+
+ MIT License - http://creativecommons.org/licenses/MIT
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+-->
+<title>OMG ITS CHARLIE SHEEN! THE Charlie Sheen!!!! :o</title>
+<script type="text/javascript">$_scruff = true;</script>
+<script src="tinted-sheen.js" type="text/javascript"></script>
+<style type="text/css">
+body {font-family: Helvetica, Arial, Verdana, sans-serif;}
+#container {text-align: center;}
+#container h1 {font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 3.2em; padding: 12px 0; margin: 0; line-height: 1.0em; color: #ff00ff;}
+#container p {padding: 12px 0; margin: 0;}
+#container p img {width: 250px; height: 300px;}
+#container p a {display: inline-block; padding: 12px 24px; margin: 0; background: #ffffff; color: #444444; line-height: 1.0em; font-size: 2.4em; font-weight: bold; border: 4px solid #cccccc; text-decoration: none;}
+#container p a.sheeny {background: #cccccc; color: #000000; border-color: #000000;}
+#container p a.sheeny:hover {border-color: #444444; background: #aaaaaa;}
+#container p a.install {font-size: 1.6em; border: none; background: none;}
+#container p a.install:hover {color: #000000; text-decoration: underline;}
+</style>
+</head>
+<body>
+<div id="container">
+ <h1>OMG! OMG! OMG!<br/> ITS CHARLIE SHEEN!!!!1! #winning #tigerblood</h1>
+ <p><img src="images/sheen_famo.jpg" title="Charlie Sheen!!!" alt="" /><img src="images/timberlake_famo.jpg" title="Not the winner!!" alt="" /></p>
+ <p><a class="sheeny" href="javascript:;" onclick="if (!this.tinted) {tinted_sheen_start(local ? jQuery : unsafeWindow.jQuery); this.tinted=true; this.innerHTML = 'Tinted!'; this.className='';} else {location.href=location.href;} return false;">Tinted Sheen!</a></p>
+ <p><a class="install" href="tinted-sheen.xpi">Like it? Install the Firefox Extension!</a></p>
+</div>
+</body>
+</html>
@@ -0,0 +1,2 @@
+content tinted-sheen content/
+overlay chrome://browser/content/browser.xul chrome://tinted-sheen/content/overlay.xul
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<overlay xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>
+ <script type='application/x-javascript' src='chrome://tinted-sheen/content/xmlhttprequester.js'></script>
+ <script type='application/x-javascript' src='chrome://tinted-sheen/content/prefman.js'></script>
+ <script type='application/x-javascript' src='chrome://tinted-sheen/content/script-compiler.js'></script>
+</overlay>
@@ -0,0 +1,92 @@
+function tinted_sheen_PrefManager() {
+ var startPoint="tinted_sheen.";
+
+ var pref=Components.classes["@mozilla.org/preferences-service;1"].
+ getService(Components.interfaces.nsIPrefService).
+ getBranch(startPoint);
+
+ var observers={};
+
+ // whether a preference exists
+ this.exists=function(prefName) {
+ return pref.getPrefType(prefName) != 0;
+ }
+
+ // returns the named preference, or defaultValue if it does not exist
+ this.getValue=function(prefName, defaultValue) {
+ var prefType=pref.getPrefType(prefName);
+
+ // underlying preferences object throws an exception if pref doesn't exist
+ if (prefType==pref.PREF_INVALID) {
+ return defaultValue;
+ }
+
+ switch (prefType) {
+ case pref.PREF_STRING: return pref.getCharPref(prefName);
+ case pref.PREF_BOOL: return pref.getBoolPref(prefName);
+ case pref.PREF_INT: return pref.getIntPref(prefName);
+ }
+ }
+
+ // sets the named preference to the specified value. values must be strings,
+ // booleans, or integers.
+ this.setValue=function(prefName, value) {
+ var prefType=typeof(value);
+
+ switch (prefType) {
+ case "string":
+ case "boolean":
+ break;
+ case "number":
+ if (value % 1 != 0) {
+ throw new Error("Cannot set preference to non integral number");
+ }
+ break;
+ default:
+ throw new Error("Cannot set preference with datatype: " + prefType);
+ }
+
+ // underlying preferences object throws an exception if new pref has a
+ // different type than old one. i think we should not do this, so delete
+ // old pref first if this is the case.
+ if (this.exists(prefName) && prefType != typeof(this.getValue(prefName))) {
+ this.remove(prefName);
+ }
+
+ // set new value using correct method
+ switch (prefType) {
+ case "string": pref.setCharPref(prefName, value); break;
+ case "boolean": pref.setBoolPref(prefName, value); break;
+ case "number": pref.setIntPref(prefName, Math.floor(value)); break;
+ }
+ }
+
+ // deletes the named preference or subtree
+ this.remove=function(prefName) {
+ pref.deleteBranch(prefName);
+ }
+
+ // call a function whenever the named preference subtree changes
+ this.watch=function(prefName, watcher) {
+ // construct an observer
+ var observer={
+ observe:function(subject, topic, prefName) {
+ watcher(prefName);
+ }
+ };
+
+ // store the observer in case we need to remove it later
+ observers[watcher]=observer;
+
+ pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal).
+ addObserver(prefName, observer, false);
+ }
+
+ // stop watching
+ this.unwatch=function(prefName, watcher) {
+ if (observers[watcher]) {
+ pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal)
+ .removeObserver(prefName, observers[watcher]);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit b442ca2

Please sign in to comment.