aremesh / StocksToBuyLinkage

// ==UserScript==
// @name         StocksToBuyLinkage
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  LinkToTradingView and Robinhood
// @author       You
// @match        https://superstocktobuy.com/*
// @grant        none
// @require      https://code.jquery.com/jquery-3.3.1.slim.js
// @require      https://openuserjs.org/src/libs/aremesh/External_Lib.js
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';
  AddPortfolioLinks();
  DetectAjaxChanges();
  // Your code here...
})();

function AddTopLinks() {
  var bullbearChart = "<td><a target='_blank' class='nav-link' href='https://bullbearcharts.blogspot.com/' class='tab-link'>Bull Bear Chart</a> </td><td><a target='_blank' class='nav-link' href='http://insiderbuyingselling.com' class='tab-link'>Insider Buying</a> </td>"
  $(".navbar td[style='width: 100%']").html(bullbearChart)
}

function AddIndLinks() {
  var stockName = window.location.search.split("&")[0].split("=")[1]
  var existing = $(".ta-settings-button").html()
  var finalLink = GenerateLinks(stockName, existing,true)
  $(".ta-settings-button").html(finalLink)
}

function AddPortfolioLinks() {
  var all = $("#myTable a");

  if (all.length === 0) {
    all = $("#body-table-portfolio td[title] a b")
  }
  all.each(function (x) {
    var isnotadded = $(this).parents("td").attr("isadded");
    var isadded = (isnotadded === null || isnotadded === undefined)
    if (isadded) {
      var stockName = $(this).html().replace("<b>", "").replace("</b>", "");
      var existing = $(this).parents("td").html();
      var finalLink =GenerateLinks(stockName, existing,true)
      $(this).parent("td").html(finalLink).attr("isadded", "true")
    }
  })
}

function DetectAjaxChanges() {
  $("#myTable_length select").trigger("change")
  $("#myTable_length select").change(function () {
    AddPortfolioLinks();
  });
}