Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
adding example file, fixing minor bugs w/ search, nicer placement and…
Browse files Browse the repository at this point in the history
… replacing of images w/ mentions in src, alt, or title attributes. minifying this script, including jquery-latested, and updating js in xpi/ folder. including newer version of xpi.
  • Loading branch information
gleuch committed May 15, 2010
1 parent 06e2287 commit dfd85c4
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 101 deletions.
37 changes: 37 additions & 0 deletions example.html
@@ -0,0 +1,37 @@
<html>
<head>
<!--
SHAVED BIEBER
Bookmarklet, Firefox extension, and inline code to clean up those lower regions of websites from Bieber mentions.
by Greg Leuch <http://www.gleuch.com>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<title>OMG ITS JUSTIN BIEBER! THE Justin Bieber!!!! :o</title>
<script type="text/javascript">var $_scruff = true;</script>
<script src="shaved-bieber.min.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.biebery {background: #cccccc; color: #000000; border-color: #000000;}
#container p a.biebery: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 JUSTIN BIEBER!!!!1!</h1>
<p><img src="images/bieber_famo.jpg" title="Justin Bieber!!!" alt="" /><img src="images/timberlake_famo.jpg" title="Not J-Bie!!" alt="" /></p>
<p><a class="biebery" href="javascript:;" onclick="if (!this.shaved) {shaved_bieber_start(local ? jQuery : unsafeWindow.jQuery); this.shaved=true; this.innerHTML = 'Shaved!'; this.className='';} else {location.href=location.href;} return false;">Shave My Bieber!</a></p>
<p><a class="install" href="shaved-bieber.xpi">Like it? Install the Firefox Extension!</a></p>
</div>
</body>
</html>
Binary file added images/bieber_famo.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/timberlake_famo.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions jquery-latest.js

Large diffs are not rendered by default.

47 changes: 12 additions & 35 deletions shaved-bieber.js
Expand Up @@ -43,7 +43,7 @@ function shaved_bieber_start($_) {
};

$_.extend($_.shaved_bieber, {
settings : {hide_bg : true, search: /(justin)(\s)?(drew\s)?(bieber|beiber)/img, replace: '<span class="shaved_bieber">SHAVED BIEBER</span>', starred: '****** ******', init : false, finish : false},
settings : {hide_bg : true, search: /(justin(\s|\-|\_))?(drew(\s|\-\_))?(bieber|beiber)/img, replace: '<span class="shaved_bieber" style="color: %C; background-color: %C;">$1$2$3$4$5</span>', starred: '****** ******', init : false, finish : false},

filter : function(self) {
if (self.nodeType == 1) {
Expand All @@ -60,7 +60,7 @@ function shaved_bieber_start($_) {
if (self.nodeType == 3) {
if (self.nodeValue.replace(/\s/ig, '') != '') {
if (!c) c = $_(self).parent() ? $_(self).parent().css('color') : '#000000';
text = self.nodeValue.replace($_.shaved_bieber.settings.search, '<span class="shaved_bieber" style="color: '+ c +'; background-color:'+c+';">$1$2$3</span>')
text = self.nodeValue.replace($_.shaved_bieber.settings.search, $_.shaved_bieber.settings.replace.replace(/\%C/mg, c) );
$_(self).after(text);
self.nodeValue = '';
}
Expand All @@ -69,7 +69,7 @@ function shaved_bieber_start($_) {
if ($_(self).children().length > 0) {
$_.shaved_bieber($_(self).contents(), c);
} else if ($_(self).children().length == 0) {
text = $_(self).html().replace($_.shaved_bieber.settings.search, '<span class="shaved_bieber" style="color: '+ c +'; background-color:'+c+';">$1$2$3$4</span>');
text = $_(self).html().replace($_.shaved_bieber.settings.search, $_.shaved_bieber.settings.replace.replace(/\%C/mg, c) );
$_(self).html(text);
}
}
Expand All @@ -84,47 +84,24 @@ function shaved_bieber_start($_) {
this.title = this.title.replace($_.shaved_bieber.settings.search, $_.shaved_bieber.settings.starred)
});

// setTimeout(function() {
// $_('object,embed,iframe').each(function() {
// var r = $_(this);
// r.wrap(document.createElement('div'));
// var s = $_(this).parent();
// s.css({width: r.width(), height: r.height()}).addClass('shaved_bieber');
// r.remove();
// });
// }, 1000);

// $_('img, input[type=image]').each(function() {
// var r = $_(this), w = r.width(), h = r.height();
// r.css({width: r.width(), height: r.height()}).attr('src', 'http://assets.gleuch.com/blank.png').width(w).height(h);
// });
$_('img, input[type=image]').each(function() {
if ($_(this).attr('alt').match($_.shaved_bieber.settings.search) || $_(this).attr('title').match($_.shaved_bieber.settings.search) || $_(this).attr('src').match($_.shaved_bieber.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);
}
});

var s = document.createElement("style");
s.innerHTML = ".shaved_bieber {font-size: inherit !important; "+ ($_.shaved_bieber.settings.hide_bg ? "background-image: none !important;" : "") +"} .bg_shaved_bieber {"+ ($_.shaved_bieber.settings.hide_bg ? "background-image: none !important;" : "") +"} select, input, textarea, object, embed, img, button, hr {background: #000 !important; color: #000 !important; border-color: #000 !important;}";
s.innerHTML = ".shaved_bieber {font-size: inherit !important; "+ ($_.shaved_bieber.settings.hide_bg ? "background-image: none !important;" : "") +"} .bg_shaved_bieber {"+ ($_.shaved_bieber.settings.hide_bg ? "background-image: none !important;" : "") +"}";
$_('head').append(s);

/*if ($_.shaved_bieber.settings.hide_bg) $_('body *, body, html').each(function() {$_(this).addClass('bg_shaved_bieber');});*/

$_.shaved_bieber.settings.finish = true;
}
});
})($_);

/* $(window).ready(function() { */
/* Remove some shitty ads */
$('iframe, a[href~=atdmt], script[src~=doubleclick]').remove();
/* }); */
/* $_(document).ready(function() { */
$_.shaved_bieber('html', '#000000');

/* setTimeout(function() {
if ($_.shaved_bieber.settings.md5 != $('*').size()) {
$_.shaved_bieber('html', '#000000');
$_.shaved_bieber.settings.md5 = $('*').size();
}
}, 2000); */
/* }); */
$_.shaved_bieber('html', '#000000');
}


shaved_bieber_wait();
if (!$_scruff) {shaved_bieber_wait();}
18 changes: 9 additions & 9 deletions shaved-bieber.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified shaved-bieber.xpi
Binary file not shown.

0 comments on commit dfd85c4

Please sign in to comment.