Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate ShareMeNot functionality #196

Merged
merged 14 commits into from
Jun 10, 2014
Merged
Prev Previous commit
Previous fix to race condition broke things when userunblock, fix in …
…better way.
  • Loading branch information
froeschele committed Jun 10, 2014
commit b2fe9cd9e20640239ad4cabd4b45defe0e155038
11 changes: 7 additions & 4 deletions src/socialwidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ var CONTENT_SCRIPT_STYLESHEET_PATH = chrome.extension.getURL("skin/socialwidgets
* Initializes the content script.
*/
function initialize() {
setTimeout(delayedInitialize, 100);
}

function delayedInitialize() {
getTrackerData(function (trackers, trackerButtonsToReplace) {
// add the Content.css stylesheet to the page
var head = document.querySelector("head");
Expand Down Expand Up @@ -243,10 +247,9 @@ function replaceScriptsRecurse(node) {
*/
function replaceTrackerButtonsHelper(trackers, trackerButtonsToReplace) {
trackers.forEach(function(tracker) {
// There's a weird race condition where background might not yet know
// about a widget to replace, so just try them all.
// If the list of buttons to replace gets long, may want to optimize here.
var replaceTrackerButtons = true;//trackerButtonsToReplace[tracker.name];
// There's a race condition where background might not yet know
// about a widget to replace, unsure how to fix.
var replaceTrackerButtons = trackerButtonsToReplace[tracker.name];

if (replaceTrackerButtons) {
//console.log("replacing tracker button for " + tracker.name);
Expand Down