Skip to content

Commit

Permalink
The initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldestlivingboy committed Jun 6, 2011
0 parents commit eb93ca0
Show file tree
Hide file tree
Showing 11 changed files with 9,172 additions and 0 deletions.
Binary file added 128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions README.markdown
@@ -0,0 +1,2 @@
A [browser extension](http://likeplusone.org/) that reduces your risk of getting
carpal tunnel syndrome up to 50% by turning Like into Like+1 buttons.
22 changes: 22 additions & 0 deletions background.html
@@ -0,0 +1,22 @@
<!--
The markup for a background page that manages interest data.
Copyright 2011 Ashkan Soltani and Brian Kennish
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
Authors (one per line):
Brian Kennish <byoogle@gmail.com>
-->
<script src="background.js"></script>
37 changes: 37 additions & 0 deletions background.js
@@ -0,0 +1,37 @@
/*
The script for a background page that manages interest data.
Copyright 2011 Ashkan Soltani and Brian Kennish
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
Authors (one per line):
Brian Kennish <byoogle@gmail.com>
*/

/* Destringifies an object. */
function deserialize(object) {
return typeof object == 'string' ? JSON.parse(object) : object;
}

/* The saved like+1s. */
var likeplusones = deserialize(localStorage.likeplusones) || {};

/* Adds or removes a like+1. */
chrome.extension.onRequest.addListener(function(request) {
var page = request.page;
request.likeplusoned ? likeplusones[page] = Date.now() :
delete likeplusones[page];
localStorage.likeplusones = JSON.stringify(likeplusones);
});
81 changes: 81 additions & 0 deletions content.css
@@ -0,0 +1,81 @@
/*
A content style sheet that munges Like buttons.
Copyright 2011 Ashkan Soltani and Brian Kennish
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
Authors (one per line):
Brian Kennish <byoogle@gmail.com>
*/
.likeplusone {
min-width: 96px;
min-height: 24px
}

.connect_widget_number_cloud { width: 56px !important }

.uiGrid .thumbs_up_icon,
.connect_widget_like_button.like_button_like .tombstone_cross {
margin-right: 0
}

.uiGrid .thumbs_up_icon {
background-image: none;
width: 0
}

.connect_widget_number_cloud_summary .connect_widget_connected_text,
.connect_widget_number_cloud_summary .connect_widget_not_connected_text {
font-size: 16px
}

.connect_widget_like_button.clearfix { padding: 2px 4px }

.connect_widget_like_button.like_button_like .tombstone_cross,
.connect_widget_like_button.clearfix.like_button_like .tombstone_cross:hover,
.connect_widget_like_button.clearfix.like_button_no_like .liketext {
background-position: 0
}

.connect_widget_like_button.like_button_like .tombstone_cross,
.like_button_no_like .liketext {
width: 48px;
height: 18px
}

.connect_widget_like_button.like_button_like .tombstone_cross {
background-image:
url(chrome-extension://lpehokhlnomihmdpgoclgbapaglbclfg/likeplusone.png)
}

.connect_widget_like_button.clearfix.like_button_no_like .liketext {
background-image:
url(chrome-extension://lpehokhlnomihmdpgoclgbapaglbclfg/unlikeplusone.png);
padding-left: 0
}

.connect_widget_like_button.like_button_like .liketext, .hidden {
display: none
}

.uiGrid .connect_widget_button_count_count {
padding-top: 2px;
padding-bottom: 4px;
font-size: 12px
}

.fbSendButton { left: 64px !important }

.connect_confirmation_cell { left: 118px !important }
67 changes: 67 additions & 0 deletions content.js
@@ -0,0 +1,67 @@
/*
A content script that munges Like buttons.
Copyright 2011 Ashkan Soltani and Brian Kennish
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
Authors (one per line):
Brian Kennish <byoogle@gmail.com>
*/

/* Messages the page and Like+1 state internally and a + or -1 externally. */
function likeplusone(likeplusoned) {
var page =
location.href.indexOf(like, 7) >= 7 ?
decodeURIComponent(location.search.split('href=', 2)[1].split('&', 1))
: location;
chrome.extension.sendRequest({page: page, likeplusoned: likeplusoned});
$('head').append(
'<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>'
);
$('body').append(
'<div class="hidden"><g:plusone href="' + page + '"></g:plusone></div>'
);

setTimeout(function() {
$('[src*="plusone.google.com/u/0/_/+1/button"]').
attr('src', function(index, source) { return source += '#like+1'; });
}, timeout);
}

/* The, partial, URL of the Like iframe. */
var like = 'www.facebook.com/plugins/like.php';

/* The +1 timeout, in milliseconds. */
var timeout = 2000;

$('[src*="' + like + '"]').addClass('likeplusone');

/* Splits the like stream. */
$('.connect_widget_like_button').
click(function() { likeplusone(true); }).
children('.liketext').html('');

/* Splits the unlike stream. */
$('.tombstone_cross').click(function() { likeplusone(); });

/* Simulates a click on the +1 button. */
setTimeout(function() {
if (location.hash.split('#').pop() == 'like+1') {
// jQuery seems to bite the bag here.
var click = document.createEvent('MouseEvents');
click.initMouseEvent('click', true, true);
document.getElementById('button').dispatchEvent(click);
}
}, timeout);

0 comments on commit eb93ca0

Please sign in to comment.