Skip to content

Commit

Permalink
1.7.7 release (fixing a bug w/ like sentence demetrication when like …
Browse files Browse the repository at this point in the history
…is clicked)
  • Loading branch information
Benjamin Grosser committed Jul 24, 2019
1 parent b16085e commit c3d6cd9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
@@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name Facebook Demetricator // @name Facebook Demetricator
// @version 1.7.6 // @version 1.7.7
// @namespace facebookdemetricator // @namespace facebookdemetricator
// @description Removes all the metrics from Facebook // @description Removes all the metrics from Facebook


Expand Down Expand Up @@ -43,7 +43,7 @@
// Winner of a Terminal Award for 2012-13 // Winner of a Terminal Award for 2012-13
// http://terminalapsu.org // http://terminalapsu.org
// //
// Version 1.7.6 // Version 1.7.7
// https://bengrosser.com/projects/facebook-demetricator/ // https://bengrosser.com/projects/facebook-demetricator/
// //
// Major Exhibitions: // Major Exhibitions:
Expand Down Expand Up @@ -90,7 +90,7 @@ var newSearchBarWidthNarrow = 350;
// constants // constants
var FADE_SPEED = 175; // used in jQuery fadeIn()/fadeOut() var FADE_SPEED = 175; // used in jQuery fadeIn()/fadeOut()
var ELEMENT_POLL_SPEED = 750; // waitForKeyElements polling interval var ELEMENT_POLL_SPEED = 750; // waitForKeyElements polling interval
var VERSION_NUMBER = '1.7.6'; // used in the console logging var VERSION_NUMBER = '1.7.7'; // used in the console logging
var KEY_CONTROL = false; // debug kb control var KEY_CONTROL = false; // debug kb control
var FAN_PAGE_URL = 'https://bengrosser.com'; var FAN_PAGE_URL = 'https://bengrosser.com';
var DEMETRICATOR_HOME_URL = 'https://bengrosser.com/projects/facebook-demetricator/'; var DEMETRICATOR_HOME_URL = 'https://bengrosser.com/projects/facebook-demetricator/';
Expand Down Expand Up @@ -1806,6 +1806,8 @@ function attachTooltipDemetricator(n) {


// receives a like sentence element as part of a reaction cluster // receives a like sentence element as part of a reaction cluster
// maybe should receive the cluster and manage from there? // maybe should receive the cluster and manage from there?
//
// this function is a hacky shitstorm
function attachReactionDemetricator2(p) { function attachReactionDemetricator2(p) {


p.addClass('facebookcount'); p.addClass('facebookcount');
Expand All @@ -1821,15 +1823,21 @@ function attachReactionDemetricator2(p) {


// clone the lsn for future demetrication toggling as a demetricated like sentence node (dlsn) // clone the lsn for future demetrication toggling as a demetricated like sentence node (dlsn)
var dlsn = olsn.clone(); var dlsn = olsn.clone();
var dlsnspan = dlsn.find('span._81hb'); // adding ._81hb jul 2019
// was -100px
dlsn.css('margin-left','0px').addClass('facebookmetric_toggleON'); dlsn.css('margin-left','0px').addClass('facebookmetric_toggleON');

var dlsnspan = dlsn.find('span._81hb').not('.fbd_demetricatedLikeSentence'); // adding ._81hb jul 2019
if(dlsnspan != undefined) {
// was -100px
//dlsnspan.removeAttr('data-tooltip-uri id').addClass('fbd_demetricatedLikeSentence'); //dlsnspan.removeAttr('data-tooltip-uri id').addClass('fbd_demetricatedLikeSentence');
dlsnspan.removeAttr('id').addClass('fbd_demetricatedLikeSentence'); dlsnspan.parent().removeAttr('id').addClass("WASHERE").attr('id','test2');
//console.log(dlsnspan.parent());
dlsnspan.removeAttr('id').addClass('fbd_demetricatedLikeSentence WASHERE').attr('id','test');


// demetricate the clone's like sentence text // demetricate the clone's like sentence text
cloneSentence = dlsnspan.text(); cloneSentence = dlsnspan.text();
//console.log("f: "+cloneSentence);
dlsnspan.text(removeMetricFromLikeSentence(cloneSentence)); dlsnspan.text(removeMetricFromLikeSentence(cloneSentence));
}


// tag and hide the original like sentence node (olsn) // tag and hide the original like sentence node (olsn)
//olsn.addClass('facebookmetric_toggleOFF').hide(); //olsn.addClass('facebookmetric_toggleOFF').hide();
Expand All @@ -1856,12 +1864,17 @@ function attachReactionDemetricator2(p) {
olsn.parent().prepend(dlsn); olsn.parent().prepend(dlsn);


// bind a listener adjust the cloned like sentence on any metric tracker updates // bind a listener adjust the cloned like sentence on any metric tracker updates
olsn.bind("DOMSubtreeModified", function() { //olsn.bind("DOMSubtreeModified", function() {
var newls = j(this).find('.fbd_origLikeSentence').text(); olsn.parent().find('._3dlg').bind("DOMSubtreeModified", function() {
//console.log("got oclick");
//if(j(this).parent().hasClass('fbd_demetricatedLikeSentence')) return;

var newls = j(this).parent().find('._81hb.fbd_origLikeSentence').text();
var dls = removeMetricFromLikeSentence(newls); var dls = removeMetricFromLikeSentence(newls);
//console.log("f2: "+dls);
// tooltip content isn't filled out until a hover event // tooltip content isn't filled out until a hover event
// var ttc = j(this).attr('data-tooltip-content'); // var ttc = j(this).attr('data-tooltip-content');
j(this).parent().find('.fbd_demetricatedLikeSentence').text(dls); j(this).parent().find('._81hb.fbd_demetricatedLikeSentence').text(dls);
}); });
} }


Expand Down Expand Up @@ -1920,10 +1933,13 @@ function attachReactionDemetricator(p) {
function removeMetricFromLikeSentence(txt) { function removeMetricFromLikeSentence(txt) {
var result = ""; var result = "";


//console.log("rmfls: "+txt);
// if this is a traditional like sentence like "You, Kate, and 8 others" // if this is a traditional like sentence like "You, Kate, and 8 others"
if(txt.contains("other") || txt.contains(",")) { if(txt.contains("other") || txt.contains(",")) {
var parsed = txt.match(/^(.*)\s+(\d+(?:[,,.]\d+)*[K|M|k|m]?)\s+(.*)/); var parsed = txt.match(/^(.*)\s+(\d+(?:[,,.]\d+)*[K|M|k|m]?)\s+(.*)/);
if(parsed) result = parsed[1] + ' ' + parsed[3]; if(parsed) {
result = parsed[1] + ' ' + parsed[3];
}
else { else {
//console.log("ERROR ON like sentence metric removal"); //console.log("ERROR ON like sentence metric removal");
result = txt; result = txt;
Expand All @@ -1936,8 +1952,11 @@ function removeMetricFromLikeSentence(txt) {
result = ""; result = "";
} }


else result = txt; else {
result = txt;
}


//console.log("returning "+result);
return result; return result;
} }


Expand Down
@@ -1,6 +1,6 @@
{ {
"name": "Facebook Demetricator", "name": "Facebook Demetricator",
"version": "1.7.6", "version": "1.7.7",
"description": "Hides all the metrics on Facebook", "description": "Hides all the metrics on Facebook",
"homepage_url": "http://bengrosser.com/projects/facebook-demetricator/", "homepage_url": "http://bengrosser.com/projects/facebook-demetricator/",
"manifest_version": 2, "manifest_version": 2,
Expand Down
41 changes: 30 additions & 11 deletions extensions/firefox/facebookdemetricator.user.js
@@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name Facebook Demetricator // @name Facebook Demetricator
// @version 1.7.6 // @version 1.7.7
// @namespace facebookdemetricator // @namespace facebookdemetricator
// @description Removes all the metrics from Facebook // @description Removes all the metrics from Facebook


Expand Down Expand Up @@ -43,7 +43,7 @@
// Winner of a Terminal Award for 2012-13 // Winner of a Terminal Award for 2012-13
// http://terminalapsu.org // http://terminalapsu.org
// //
// Version 1.7.6 // Version 1.7.7
// https://bengrosser.com/projects/facebook-demetricator/ // https://bengrosser.com/projects/facebook-demetricator/
// //
// Major Exhibitions: // Major Exhibitions:
Expand Down Expand Up @@ -90,7 +90,7 @@ var newSearchBarWidthNarrow = 350;
// constants // constants
var FADE_SPEED = 175; // used in jQuery fadeIn()/fadeOut() var FADE_SPEED = 175; // used in jQuery fadeIn()/fadeOut()
var ELEMENT_POLL_SPEED = 750; // waitForKeyElements polling interval var ELEMENT_POLL_SPEED = 750; // waitForKeyElements polling interval
var VERSION_NUMBER = '1.7.6'; // used in the console logging var VERSION_NUMBER = '1.7.7'; // used in the console logging
var KEY_CONTROL = false; // debug kb control var KEY_CONTROL = false; // debug kb control
var FAN_PAGE_URL = 'https://bengrosser.com'; var FAN_PAGE_URL = 'https://bengrosser.com';
var DEMETRICATOR_HOME_URL = 'https://bengrosser.com/projects/facebook-demetricator/'; var DEMETRICATOR_HOME_URL = 'https://bengrosser.com/projects/facebook-demetricator/';
Expand Down Expand Up @@ -1806,6 +1806,8 @@ function attachTooltipDemetricator(n) {


// receives a like sentence element as part of a reaction cluster // receives a like sentence element as part of a reaction cluster
// maybe should receive the cluster and manage from there? // maybe should receive the cluster and manage from there?
//
// this function is a hacky shitstorm
function attachReactionDemetricator2(p) { function attachReactionDemetricator2(p) {


p.addClass('facebookcount'); p.addClass('facebookcount');
Expand All @@ -1821,15 +1823,21 @@ function attachReactionDemetricator2(p) {


// clone the lsn for future demetrication toggling as a demetricated like sentence node (dlsn) // clone the lsn for future demetrication toggling as a demetricated like sentence node (dlsn)
var dlsn = olsn.clone(); var dlsn = olsn.clone();
var dlsnspan = dlsn.find('span._81hb'); // adding ._81hb jul 2019
// was -100px
dlsn.css('margin-left','0px').addClass('facebookmetric_toggleON'); dlsn.css('margin-left','0px').addClass('facebookmetric_toggleON');

var dlsnspan = dlsn.find('span._81hb').not('.fbd_demetricatedLikeSentence'); // adding ._81hb jul 2019
if(dlsnspan != undefined) {
// was -100px
//dlsnspan.removeAttr('data-tooltip-uri id').addClass('fbd_demetricatedLikeSentence'); //dlsnspan.removeAttr('data-tooltip-uri id').addClass('fbd_demetricatedLikeSentence');
dlsnspan.removeAttr('id').addClass('fbd_demetricatedLikeSentence'); dlsnspan.parent().removeAttr('id').addClass("WASHERE").attr('id','test2');
//console.log(dlsnspan.parent());
dlsnspan.removeAttr('id').addClass('fbd_demetricatedLikeSentence WASHERE').attr('id','test');


// demetricate the clone's like sentence text // demetricate the clone's like sentence text
cloneSentence = dlsnspan.text(); cloneSentence = dlsnspan.text();
//console.log("f: "+cloneSentence);
dlsnspan.text(removeMetricFromLikeSentence(cloneSentence)); dlsnspan.text(removeMetricFromLikeSentence(cloneSentence));
}


// tag and hide the original like sentence node (olsn) // tag and hide the original like sentence node (olsn)
//olsn.addClass('facebookmetric_toggleOFF').hide(); //olsn.addClass('facebookmetric_toggleOFF').hide();
Expand All @@ -1856,12 +1864,17 @@ function attachReactionDemetricator2(p) {
olsn.parent().prepend(dlsn); olsn.parent().prepend(dlsn);


// bind a listener adjust the cloned like sentence on any metric tracker updates // bind a listener adjust the cloned like sentence on any metric tracker updates
olsn.bind("DOMSubtreeModified", function() { //olsn.bind("DOMSubtreeModified", function() {
var newls = j(this).find('.fbd_origLikeSentence').text(); olsn.parent().find('._3dlg').bind("DOMSubtreeModified", function() {
//console.log("got oclick");
//if(j(this).parent().hasClass('fbd_demetricatedLikeSentence')) return;

var newls = j(this).parent().find('._81hb.fbd_origLikeSentence').text();
var dls = removeMetricFromLikeSentence(newls); var dls = removeMetricFromLikeSentence(newls);
//console.log("f2: "+dls);
// tooltip content isn't filled out until a hover event // tooltip content isn't filled out until a hover event
// var ttc = j(this).attr('data-tooltip-content'); // var ttc = j(this).attr('data-tooltip-content');
j(this).parent().find('.fbd_demetricatedLikeSentence').text(dls); j(this).parent().find('._81hb.fbd_demetricatedLikeSentence').text(dls);
}); });
} }


Expand Down Expand Up @@ -1920,10 +1933,13 @@ function attachReactionDemetricator(p) {
function removeMetricFromLikeSentence(txt) { function removeMetricFromLikeSentence(txt) {
var result = ""; var result = "";


//console.log("rmfls: "+txt);
// if this is a traditional like sentence like "You, Kate, and 8 others" // if this is a traditional like sentence like "You, Kate, and 8 others"
if(txt.contains("other") || txt.contains(",")) { if(txt.contains("other") || txt.contains(",")) {
var parsed = txt.match(/^(.*)\s+(\d+(?:[,,.]\d+)*[K|M|k|m]?)\s+(.*)/); var parsed = txt.match(/^(.*)\s+(\d+(?:[,,.]\d+)*[K|M|k|m]?)\s+(.*)/);
if(parsed) result = parsed[1] + ' ' + parsed[3]; if(parsed) {
result = parsed[1] + ' ' + parsed[3];
}
else { else {
//console.log("ERROR ON like sentence metric removal"); //console.log("ERROR ON like sentence metric removal");
result = txt; result = txt;
Expand All @@ -1936,8 +1952,11 @@ function removeMetricFromLikeSentence(txt) {
result = ""; result = "";
} }


else result = txt; else {
result = txt;
}


//console.log("returning "+result);
return result; return result;
} }


Expand Down

0 comments on commit c3d6cd9

Please sign in to comment.