Browse Source

Remove N/A showing.

master
Kuzirashi 6 years ago
parent
commit
c8d562c947
  1. 2
      src/config.js
  2. 19
      src/content-scripts/twitter/js/ProfileHoverPopupScore.js
  3. 23
      src/content-scripts/twitter/js/ProfileScore.js
  4. 20
      src/content-scripts/twitter/js/TweetsAuthorScore.js

2
src/config.js

@ -9,8 +9,6 @@ export const CONFIG = {
topFollowersCluster: 'Crypto'
},
MAX_SCORE: 1000,
NO_SCORE_TEXT: 'N/A',
NO_SCORE_TOOLTIP: `Account hasn't been indexed yet`,
GOOGLE_ANALYTICS_ID: 'UA-39572645-2'
};

19
src/content-scripts/twitter/js/ProfileHoverPopupScore.js

@ -1,5 +1,3 @@
import { CONFIG } from '../../../config';
const PROFILE_HOVER_CONTAINER = '#profile-hover-container';
const ELEMENT_CLASS = 'HiveExtension-Twitter_profile-hover-popup';
@ -62,28 +60,25 @@ export class TwitterProfileHoverPopupScoreExtension {
defaultClusterName,
accountIndexed
) {
let tooltip = CONFIG.NO_SCORE_TOOLTIP;
if (!accountIndexed) {
return;
}
let tooltip = '';
let label = '';
let value = CONFIG.NO_SCORE_TEXT;
let value = '';
const option = await this._settings.getOptionValue('displaySetting');
if (
accountIndexed &&
['showRanksWithScoreFallback', 'showRanks'].includes(option) &&
defaultClusterRank
) {
if (['showRanksWithScoreFallback', 'showRanks'].includes(option) && defaultClusterRank) {
value = `${defaultClusterRank}`;
label = `${defaultClusterName} Rank`;
tooltip = `${defaultClusterName} Rank ${defaultClusterRank}`;
} else if (option !== 'showRanks') {
label = `${defaultClusterName} Score`;
if (accountIndexed) {
value = Math.round(defaultClusterScore);
tooltip = `${defaultClusterName} Score ${value}`;
}
}
const displayElement = document.createElement('li');
displayElement.classList.add('ProfileCardStats-stat');

23
src/content-scripts/twitter/js/ProfileScore.js

@ -61,28 +61,25 @@ export class TwitterProfileScoreExtension {
defaultClusterName,
accountIndexed
) {
let tooltip = CONFIG.NO_SCORE_TOOLTIP;
if (!accountIndexed) {
return;
}
let tooltip = '';
let label = '';
let value = CONFIG.NO_SCORE_TEXT;
let value = '';
const option = await this._settings.getOptionValue('displaySetting');
if (
accountIndexed &&
['showRanksWithScoreFallback', 'showRanks'].includes(option) &&
defaultClusterRank
) {
if (['showRanksWithScoreFallback', 'showRanks'].includes(option) && defaultClusterRank) {
value = `${defaultClusterRank}`;
label = `${defaultClusterName} Rank`;
tooltip = `${defaultClusterName} Rank ${defaultClusterRank}`;
} else if (option !== 'showRanks') {
label = `${defaultClusterName} Score`;
if (accountIndexed) {
value = Math.round(defaultClusterScore);
tooltip = `${defaultClusterName} Score ${value}`;
}
}
const displayElement = document.createElement('div');
displayElement.classList.add('ProfileNav-item');
@ -95,14 +92,8 @@ export class TwitterProfileScoreExtension {
</div>
`;
if (label) {
if (accountIndexed) {
const popup = new ProfilePopup(this.getUserId(), this._api, this._settings);
popup.showOnClick(displayElement);
}
} else {
displayElement.style.display = 'none';
}
document
.querySelector('.ProfileNav-item:nth-of-type(4)')

20
src/content-scripts/twitter/js/TweetsAuthorScore.js

@ -1,5 +1,4 @@
import { ProfilePopup } from './ProfilePopup';
import { CONFIG } from '../../../config';
const TWEET_AUTHOR_SCORE_CLASS = 'HiveExtension-Twitter_tweet-author-score';
const TWEET_INDIVIDUAL_SCORE_CLASS = 'HiveExtension-Twitter_tweet-individual-score';
@ -86,6 +85,10 @@ export class TwitterTweetsAuthorScoreExtension {
indexed: accountIndexed
} = await this._api.getTwitterUserScore(authorId);
if (!accountIndexed) {
return;
}
const tweetIsThread =
Boolean(tweet.querySelector('.self-thread-tweet-cta')) ||
tweet.classList.contains('conversation-tweet') ||
@ -103,14 +106,10 @@ export class TwitterTweetsAuthorScoreExtension {
const option = await this._settings.getOptionValue('displaySetting');
const useIcons = await this._settings.getOptionValue('useIcons');
let value = option === 'showRanks' ? '' : CONFIG.NO_SCORE_TEXT;
let tooltip = option === 'showRanks' ? '' : CONFIG.NO_SCORE_TOOLTIP;
let value = '';
let tooltip = '';
if (
accountIndexed &&
['showRanksWithScoreFallback', 'showRanks'].includes(option) &&
defaultClusterRank
) {
if (['showRanksWithScoreFallback', 'showRanks'].includes(option) && defaultClusterRank) {
value = defaultClusterRank;
if (!useIcons) {
@ -118,7 +117,7 @@ export class TwitterTweetsAuthorScoreExtension {
}
tooltip = `${defaultClusterName} Rank ${defaultClusterRank}`;
} else if (accountIndexed && option !== 'showRanks') {
} else if (option !== 'showRanks') {
value = Math.round(userScore);
if (!useIcons) {
@ -126,9 +125,6 @@ export class TwitterTweetsAuthorScoreExtension {
}
tooltip = `${defaultClusterName} Score ${value}`;
} else if (option === 'showRanks' && !accountIndexed) {
value = '';
tooltip = '';
}
if (!value || !tooltip) {

Loading…
Cancel
Save