From 74926a7022565d94332a15c5bcd9677dcbaac547 Mon Sep 17 00:00:00 2001 From: gedro Date: Wed, 25 Nov 2015 22:45:28 +0100 Subject: [PATCH] remove the owner informations, close #2 --- .../js/extended_twitter_profile_info.js | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/chrome/src/inject/js/extended_twitter_profile_info.js b/chrome/src/inject/js/extended_twitter_profile_info.js index 9c05f5a..7593738 100644 --- a/chrome/src/inject/js/extended_twitter_profile_info.js +++ b/chrome/src/inject/js/extended_twitter_profile_info.js @@ -1,4 +1,4 @@ -function etpiDataLoader() { +function etpiDataLoader(ownerUserID) { jQuery(".expanding-stream-item").each(function () { var that = jQuery(this); @@ -6,28 +6,30 @@ function etpiDataLoader() { 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"); + } + }); + } } }); } @@ -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); } }); }