Skip to content

Commit

Permalink
remove the owner informations, close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
gedro committed Nov 25, 2015
1 parent a8ed4a3 commit 74926a7
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions chrome/src/inject/js/extended_twitter_profile_info.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
function etpiDataLoader() {
function etpiDataLoader(ownerUserID) {
jQuery(".expanding-stream-item").each(function () {
var that = jQuery(this);

if(that.children(".ProfileCardStats").length === 0 && !that.hasClass("etpi-inserted")) {
var dataUserIdElement = that.find(".original-tweet[data-user-id]");
var dataUserID = dataUserIdElement.attr("data-user-id");

jQuery.ajax({
url: "https://twitter.com/i/profiles/popup",
type: "get",
data:{user_id: dataUserID, wants_hovercard: true},
success: function(response) {
this.workOnResponseJson(that, response);
},
error: function(xhr) {
if(xhr.status === 200) {
this.workOnResponseJson(that, xhr.responseText);
}
},
workOnResponseJson: function(that, jsonText) {
var response = jQuery.parseJSON(jsonText);
if(dataUserID !== ownerUserID) {
jQuery.ajax({
url: "https://twitter.com/i/profiles/popup",
type: "get",
data:{user_id: dataUserID, wants_hovercard: true},
success: function(response) {
this.workOnResponseJson(that, response);
},
error: function(xhr) {
if(xhr.status === 200) {
this.workOnResponseJson(that, xhr.responseText);
}
},
workOnResponseJson: function(that, jsonText) {
var response = jQuery.parseJSON(jsonText);

that.find(".stream-item-header")
.find(".time")
.after(jQuery(response.html).find("div.ProfileCardStats"));
that.find(".stream-item-header")
.find(".time")
.after(jQuery(response.html).find("div.ProfileCardStats"));

that.addClass("etpi-inserted");
}
});
that.addClass("etpi-inserted");
}
});
}
}
});
}
Expand All @@ -37,12 +39,15 @@ chrome.extension.sendMessage({}, function(response) {
if (document.readyState === "complete") {
clearInterval(readyStateCheckInterval);

var ownerUserIdElement = jQuery("#user-dropdown").find(".avatar[data-user-id]");
var ownerUserID = ownerUserIdElement.attr("data-user-id");

var totalCount = jQuery(".expanding-stream-item").length;
etpiDataLoader();
etpiDataLoader(ownerUserID);
$("#stream-items-id").bind("DOMSubtreeModified", function() {
if(jQuery(".expanding-stream-item").length > totalCount) {
totalCount = jQuery(".expanding-stream-item").length;
etpiDataLoader();
etpiDataLoader(ownerUserID);
}
});
}
Expand Down

0 comments on commit 74926a7

Please sign in to comment.