Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions bg.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
if (changeInfo.status !== 'complete') {
return;
}

var date = new Date();
var blackOutHasTriggered = localStorage['blackOutComplete'];

if (
date.getMonth()==0 && date.getFullYear()==2012 && date.getDate()==18
&& !blackOutHasTriggered
) {
chrome.tabs.executeScript(tabId, { file: 'blackout.js' });
localStorage['blackOutComplete'] = true;
}

var host = getDomain(tab);
if (domains.indexOf(host) !== -1) {
if (!isIgnored(host)) {
chrome.tabs.executeScript(tabId, { file: 'sopa.js' });
chrome.pageAction.setIcon({ tabId: tabId, path: 'icon.png' });
if(typeof localStorage['boycott_mode'] === "undefined" || localStorage['boycott_mode'] == "false") {
chrome.tabs.executeScript(tabId, { file: 'sopa.js' });
chrome.pageAction.setIcon({ tabId: tabId, path: 'icon.png' });
} else {
chrome.tabs.executeScript(tabId, { file: 'blackout.js' });
}
} else {
chrome.pageAction.setIcon({ tabId: tabId, path: 'icon_ignored.png' });
}
Expand Down
5 changes: 2 additions & 3 deletions blackout.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
if (!document.getElementById('SOPABlackout')) {
var content = "<div id='SOPABlackout' style='"
+ "background: #000; top: 0; bottom:0; left:0;right:0;text-align: center;"
+ "z-index: 99999; font-size: 28px; line-height: 1.5;padding-top:400px;"
+ "z-index: 99999; font-size: 28px; line-height: 1.5;padding: 400px 0 1000px 0;"
+ "color: #fff; font-family: Helvetica, Arial;"
+ "'>"
+ "<span style='font-weight: bold;'>SOPA BLACK OUT</span>"
+ "<div id='SOPABlackoutClose' style='color:#fff;cursor:pointer;font-weight:bold;float:right;width:20px'>&times;</div>"
+ "</div>";
document.body.innerHTML = content + document.body.innerHTML;
var close = document.getElementById('SOPABlackoutClose');

close.addEventListener('click',function() {
document.getElementById('SOPABlackout').style.display = 'none';

});
} else {
document.getElementById('SOPABlackout').style.display = 'block';
Expand Down
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.11",
"description": "Be notified if you're visiting the website of a company that supports the dangerous Stop Online Piracy Act legislation.",
"background_page": "bg.html",
"options_page": "options.html",
"page_action": {
"default_icon": "icon.png",
"default_title": "Known Internet Blacklist Legislation Supporter! Click to toggle this popup."
Expand Down
32 changes: 32 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<html>
<head>
<title>No SOPA Options</title>
</head>
<script type="text/javascript">
function save_options() {

// Save option to local storage
localStorage["boycott_mode"]=document.getElementById("boycott_mode").checked;

// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML="[saving...]";
setTimeout(function(){status.innerHTML="";},750);
}

function restore_options() {
document.getElementById("boycott_mode").checked=(localStorage["boycott_mode"]==="false")?false:true
}

</script>

<body onload="restore_options()">

<div style="width: 300px;">
<input type="checkbox" id="boycott_mode" onchange="save_options()" />
<label for="boycott_mode">Boycott Mode! <span id="status" style="font-size: 80%;"></span></label>
<p style="margin: 3px 0 0 22px; font-size: 85%">When enabled replaces entire page content with example SOPA block screen instead of showing only informative bar at the top of a page.</p>
</div>

</body>
</html>
5 changes: 2 additions & 3 deletions sopa.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ if (!document.getElementById('stopSOPA')) {
+ "This company may be a supporter of the dangerous SOPA or PIPA legislation."
+ "<div style='color:#fff;font-weight:bold;float:right;padding-right:8px;width:46px;'>"
+ "<a target='_blank' style='color:#fff;font-weight:normal;font-size:0.8em;padding-right:4px;' href='http://www.reddit.com/help/faqs/sopa'>?</a> "
+ "<span id='stopSOPAClose' style='cursor:pointer;'>&times;</div>"
+ "<span id='stopSOPAClose' style='cursor:pointer;'>&times;</div>"
+ "</div></div>";
document.body.innerHTML = content + document.body.innerHTML;
var close = document.getElementById('stopSOPAClose');

close.addEventListener('click',function() {
document.getElementById('stopSOPA').style.display = 'none';

});
} else {
document.getElementById('stopSOPA').style.display = 'block';
Expand Down