Skip to content

Commit

Permalink
Merge pull request #196 from froeschele/sharemenot
Browse files Browse the repository at this point in the history
Integrate ShareMeNot functionality. Fixes #84
  • Loading branch information
cooperq committed Jun 10, 2014
2 parents 88bc855 + b2fe9cd commit 4abeec7
Show file tree
Hide file tree
Showing 17 changed files with 3,041 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ buildtools/jshydra/mozilla/js

#zip files
*.zip

#Mac DS_Store
*.DS_Store
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"src/blockedDomainList.js",
"src/webrequest.js",
"src/heuristicblocking.js",
"src/socialwidgetloader.js",
"src/background.js"
]
},
Expand All @@ -47,6 +48,16 @@
],
"all_frames": true,
"run_at": "document_start"
},
{
"js": [
"src/socialwidgets.js"
],
"matches": [
"<all_urls>"
],
"all_frames": true,
"run_at": "document_idle"
}
],
"default_locale": "en_US",
Expand Down
56 changes: 56 additions & 0 deletions skin/socialwidgets.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Privacy Badger <https://eff.org/privacybadger>
* Copyright (C) 2014 Electronic Frontier Foundation
* Derived from ShareMeNot
* Copyright (C) 2011-2014 University of Washington
*
* Privacy Badger is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Privacy Badger 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 Privacy Badger. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* ShareMeNot is licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright (c) 2011-2014 University of Washington
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

.privacyBadgerReplacementButton {
border: none !important;
cursor: pointer !important;
height: auto !important;
width: auto !important;
}

.privacyBadgerOriginalButton {
border: none !important;
height: 1.5em !important;
}
111 changes: 111 additions & 0 deletions skin/socialwidgets/AddThis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
332 changes: 332 additions & 0 deletions skin/socialwidgets/Digg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 299 additions & 0 deletions skin/socialwidgets/Facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 299 additions & 0 deletions skin/socialwidgets/Google Plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
321 changes: 321 additions & 0 deletions skin/socialwidgets/LinkedIn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
321 changes: 321 additions & 0 deletions skin/socialwidgets/Pinterest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
311 changes: 311 additions & 0 deletions skin/socialwidgets/StumbleUpon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
321 changes: 321 additions & 0 deletions skin/socialwidgets/Twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ var Synchronizer = require("synchronizer").Synchronizer;
var Utils = require("utils").Utils;
var CookieBlockList = require("cookieblocklist").CookieBlockList;
var BlockedDomainList = require("blockedDomainList").BlockedDomainList;
var HeuristicBlocking = require("heuristicblocking")
var HeuristicBlocking = require("heuristicblocking");
var SocialWidgetLoader = require("socialwidgetloader");

// Load social widgets
var SocialWidgetList = SocialWidgetLoader.loadSocialWidgetsFromFile("src/socialwidgets.json");

// Some types cannot be distinguished
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
Expand Down Expand Up @@ -481,7 +485,8 @@ chrome.extension.onRequest.addListener(function(request, sender, sendResponse)
frameId = getFrameId(tabId, request.documentUrl);
}

if (isFrameWhitelisted(tabId, frameId, "DOCUMENT"))
if (isFrameWhitelisted(tabId, frameId, "DOCUMENT")
|| isSocialWidgetTemporaryUnblock(tabId, request.url, frameId))
{
sendResponse(false);
break;
Expand Down
121 changes: 121 additions & 0 deletions src/socialwidgetloader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* This file is part of Privacy Badger <https://eff.org/privacybadger>
* Copyright (C) 2014 Electronic Frontier Foundation
* Derived from ShareMeNot
* Copyright (C) 2011-2014 University of Washington
*
* Privacy Badger is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Privacy Badger 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 Privacy Badger. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* ShareMeNot is licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright (c) 2011-2014 University of Washington
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

require.scopes["socialwidgetloader"] = (function() {

var exports = {};
exports.loadSocialWidgetsFromFile = loadSocialWidgetsFromFile;

/**
* Loads a JSON file at filePath and returns the parsed object.
*
* @param {String} filePath the path to the JSON file, relative to the
* extension's data folder
* @return {Object} the JSON at the file at filePath
*/
function loadJSONFromFile(filePath) {
var jsonString = getFileContents(filePath);
var jsonParsed = JSON.parse(jsonString);
Object.freeze(jsonParsed); // prevent modifications to jsonParsed

return jsonParsed;
}

/**
* Returns the contents of the file at filePath.
*
* @param {String} filePath the path to the file
*
* @return {String} the contents of the file
*/
function getFileContents(filePath) {
var url = chrome.extension.getURL(filePath);

var request = new XMLHttpRequest();
request.open("GET", url, false);
request.send();

return request.responseText;
}

/**
* Returns an array of SocialWidget objects that are loaded from the file at
* filePath.
*
* @param {String} filePath the path to the JSON file, relative to the
* extension's data folder
* @return {Array} an array of SocialWidget objects that are loaded from the file at
* filePath
*/
function loadSocialWidgetsFromFile(filePath) {
var socialwidgets = [];
var socialwidgetsJson = loadJSONFromFile(filePath);

// loop over each socialwidget, making a SocialWidget object
for (var socialwidgetName in socialwidgetsJson) {
var socialwidgetProperties = socialwidgetsJson[socialwidgetName];
var socialwidgetObject = new SocialWidget(socialwidgetName, socialwidgetProperties);
socialwidgets.push(socialwidgetObject);
}

return socialwidgets;
}

/**
* Constructs a SocialWidget with the given name and properties.
*
* @param {String} name the name of the socialwidget
* @param {Object} properties the properties of the socialwidget
*/
function SocialWidget(name, properties) {
this.name = name;

for (var property in properties) {
this[property] = properties[property];
}
}

return exports;
})(); //require scopes
Loading

0 comments on commit 4abeec7

Please sign in to comment.