Remove code for deprecated per-forum profiles in CC

Fixed: twpowertools:80
Change-Id: Idb8734a7a9c1c6f53a133426b1621fd53fc31a96
diff --git a/src/contentScripts/communityConsole/main.js b/src/contentScripts/communityConsole/main.js
index eaff3ce..fe075d9 100644
--- a/src/contentScripts/communityConsole/main.js
+++ b/src/contentScripts/communityConsole/main.js
@@ -6,7 +6,6 @@
 import {batchLock} from './batchLock.js';
 import {injectDarkModeButton, isDarkThemeOn} from './darkMode.js';
 import {applyDragAndDropFixIfEnabled} from './dragAndDropFix.js';
-import {injectPreviousPostsLinksIfEnabled} from './profileHistoryLink.js';
 import {unifiedProfilesFix} from './unifiedProfiles.js';
 
 var mutationObserver, intersectionObserver, intersectionOptions, options,
@@ -20,9 +19,7 @@
   // Load more bar (for the "load more"/"load all" buttons)
   '.load-more-bar',
 
-  // Username span/editor inside ec-user (user profile view)
-  'ec-user .main-card .header > .name > span',
-  'ec-user .main-card .header > .name > ec-display-name-editor',
+  // Username span/editor inside ec-unified-user (user profile view)
   'ec-unified-user .scTailwindUser_profileUsercarddetails',
 
   // Rich text editor
@@ -91,14 +88,6 @@
 
     // Show the "previous posts" links if the option is currently enabled.
     //   Here we're selecting the 'ec-user > div' element (unique child)
-
-    // TODO(b/twpowertools/80): Remove this:
-    if (node.matches('ec-user .main-card .header > .name > span') ||
-        node.matches(
-            'ec-user .main-card .header > .name > ec-display-name-editor')) {
-      injectPreviousPostsLinksIfEnabled(node);
-    }
-
     if (node.matches(
             'ec-unified-user .scTailwindUser_profileUsercarddetails')) {
       injectPreviousPostsLinksUnifiedProfileIfEnabled(
diff --git a/src/contentScripts/communityConsole/profileHistoryLink.js b/src/contentScripts/communityConsole/profileHistoryLink.js
deleted file mode 100644
index 44c7ebb..0000000
--- a/src/contentScripts/communityConsole/profileHistoryLink.js
+++ /dev/null
@@ -1,70 +0,0 @@
-import {createImmuneLink} from '../../common/commonUtils.js';
-import {escapeUsername, getAuthUser} from '../../common/communityConsoleUtils.js';
-import {isOptionEnabled} from '../../common/optionsUtils.js';
-
-import {createExtBadge, getNParent} from './utils/common.js';
-
-var authuser = getAuthUser();
-
-function addProfileHistoryLink(node, type, query) {
-  var urlpart = encodeURIComponent('query=' + query);
-  var authuserpart =
-      (authuser == '0' ? '' : '?authuser=' + encodeURIComponent(authuser));
-  var container = document.createElement('div');
-  container.style.margin = '3px 0';
-
-  var link = createImmuneLink();
-  link.setAttribute(
-      'href',
-      'https://support.google.com/s/community/search/' + urlpart +
-          authuserpart);
-  link.innerText = chrome.i18n.getMessage('inject_previousposts_' + type);
-
-  container.appendChild(link);
-  node.appendChild(container);
-}
-
-export function injectPreviousPostsLinks(nameElement) {
-  var mainCardContent = getNParent(nameElement, 3);
-  if (mainCardContent === null) {
-    console.error(
-        '[previousposts] Couldn\'t find |.main-card-content| element.');
-    return;
-  }
-
-  var forumId = location.href.split('/forum/')[1].split('/')[0] || '0';
-
-  var nameTag =
-      (nameElement.tagName == 'EC-DISPLAY-NAME-EDITOR' ?
-           nameElement.querySelector('.top-section > span') ?? nameElement :
-           nameElement);
-  var name = escapeUsername(nameTag.textContent);
-  var query1 = encodeURIComponent(
-      '(creator:"' + name + '" | replier:"' + name + '") forum:' + forumId);
-  var query2 = encodeURIComponent(
-      '(creator:"' + name + '" | replier:"' + name + '") forum:any');
-
-  var container = document.createElement('div');
-  container.classList.add('TWPT-previous-posts');
-
-  let badge, badgeTooltip;
-  [badge, badgeTooltip] = createExtBadge();
-  container.appendChild(badge);
-
-  var linkContainer = document.createElement('div');
-  linkContainer.classList.add('TWPT-previous-posts--links');
-
-  addProfileHistoryLink(linkContainer, 'forum', query1);
-  addProfileHistoryLink(linkContainer, 'all', query2);
-
-  container.appendChild(linkContainer);
-
-  mainCardContent.appendChild(container);
-  new MDCTooltip(badgeTooltip);
-}
-
-export function injectPreviousPostsLinksIfEnabled(nameElement) {
-  isOptionEnabled('history').then(isEnabled => {
-    if (isEnabled) injectPreviousPostsLinks(nameElement);
-  });
-}
diff --git a/src/contentScripts/profile.js b/src/contentScripts/profile.js
index 0bb1a7d..3f7a3fa 100644
--- a/src/contentScripts/profile.js
+++ b/src/contentScripts/profile.js
@@ -1,91 +1,8 @@
-import {escapeUsername} from '../common/communityConsoleUtils.js';
 import {getOptions} from '../common/optionsUtils.js';
-import {createPlainTooltip} from '../common/tooltip.js';
 
-import {getSearchUrl, injectPreviousPostsLinksUnifiedProfile} from './utilsCommon/unifiedProfiles.js';
-
-// TODO(b/twpowertools/80): Remove this code.
-function injectPreviousPostsLinksOldProfile() {
-  if (document.querySelector('.user-profile__user-links') === null) {
-    var nameElement = document.querySelector('.user-profile__user-name');
-    if (nameElement !== null) {
-      var profileLink = document.querySelector('.community-console');
-      if (profileLink === null) {
-        console.error(
-            '[previousposts] ' +
-            'The user is not a PE so we can\'t show the previous posts link.');
-        return;
-      }
-
-      var profileUrl = profileLink.href || '';
-      var profileUrlSplit = profileUrl.split('/forum/');
-      if (profileUrlSplit.length < 2) {
-        console.error('[previousposts] Can\'t get forum id.');
-        return;
-      }
-
-      var forumId = profileUrlSplit[1].split('/')[0];
-      var name = escapeUsername(nameElement.textContent);
-      var filter =
-          '(creator:"' + name + '" | replier:"' + name + '") forum:' + forumId;
-      var url = getSearchUrl(filter);
-
-      var links = document.createElement('div');
-      links.classList.add('user-profile__user-links');
-
-      var linkTitle = document.createElement('div');
-      linkTitle.classList.add('user-profile__user-link-title');
-      linkTitle.textContent = chrome.i18n.getMessage('inject_links');
-
-      links.appendChild(linkTitle);
-
-      var ul = document.createElement('ul');
-
-      var li = document.createElement('li');
-      li.classList.add('user-profile__user-link');
-
-      var a = document.createElement('a');
-      a.classList.add('user-profile__user-link', 'TWPT-user-link');
-      a.href = url;
-      a.setAttribute(
-          'data-stats-id', 'user-posts-link--tw-power-tools-by-avm99963');
-
-      var badge = document.createElement('span');
-      badge.classList.add('TWPT-badge');
-
-      var badgeImg = document.createElement('img');
-      badgeImg.src =
-          'https://fonts.gstatic.com/s/i/materialicons/repeat/v6/24px.svg';
-
-      badge.appendChild(badgeImg);
-      a.appendChild(badge);
-
-      var span = document.createElement('span');
-      span.textContent = chrome.i18n.getMessage('inject_previousposts');
-
-      a.appendChild(span);
-      li.appendChild(a);
-      ul.appendChild(li);
-      links.appendChild(ul);
-
-      document.querySelector('.user-profile__user-details-container')
-          .appendChild(links);
-
-      createPlainTooltip(
-          badge, chrome.i18n.getMessage('inject_extension_badge_helper', [
-            chrome.i18n.getMessage('appName')
-          ]));
-    } else {
-      console.error('[previousposts] Can\'t find username.');
-    }
-  }
-}
+import {injectPreviousPostsLinksUnifiedProfile} from './utilsCommon/unifiedProfiles.js';
 
 getOptions('history').then(options => {
-  if (options?.history) {
-    if (document.getElementById('unified-user-profile') !== null)
-      injectPreviousPostsLinksUnifiedProfile(/* isCommunityConsole = */ false);
-    else
-      injectPreviousPostsLinksOldProfile();
-  }
+  if (options?.history)
+    injectPreviousPostsLinksUnifiedProfile(/* isCommunityConsole = */ false);
 });
diff --git a/src/static/css/ccdarktheme.css b/src/static/css/ccdarktheme.css
index d61be88..f26c1ed 100644
--- a/src/static/css/ccdarktheme.css
+++ b/src/static/css/ccdarktheme.css
@@ -602,30 +602,7 @@
  * footer.
  **/
 
-/* Old profile view */
-/* TODO(b/twpowertools/80): Remove this code. */
-ec-user .main-card {
-  background-color: var(--TWPT-secondary-background)!important;
-}
-
-ec-user .abuse-alert-container {
-  background-color: var(--TWPT-active-background)!important;
-  border-top-right-radius: 8px!important;
-}
-
-ec-user .abuse-alert-container .abuse-alert {
-  color: var(--TWPT-primary-text)!important;
-}
-
-ec-user ec-display-name-editor, ec-user .header .name {
-  color: var(--TWPT-primary-text)!important;
-}
-
-ec-user .role {
-  filter: brightness(1.5);
-}
-
-/* Chart in both old and new profile view */
+/* Chart in the profile view */
 ec-user bar-chart .axis text,
     ec-unified-user sc-tailwind-shared-activity-chart .axis text {
   fill: rgba(255, 255, 255, .54)!important;
diff --git a/src/static/css/common/console.css b/src/static/css/common/console.css
index e8a6cfc..96cb5b9 100644
--- a/src/static/css/common/console.css
+++ b/src/static/css/common/console.css
@@ -42,18 +42,6 @@
   padding: 4px 8px!important;
 }
 
-/* TODO(b/twpowertools/80): Remove this code. */
-.TWPT-previous-posts {
-  display: flex;
-  flex-direction: row;
-  align-items: center;
-}
-
-.TWPT-previous-posts .TWPT-badge {
-  --icon-size: 18px;
-  margin-right: 8px;
-}
-
 /* Unified profiles "previous posts" link badge */
 .TWPT-user-link .TWPT-badge {
   display: inline-flex;