aremesh / InsiderTrading Links

// ==UserScript==
// @name         InsiderTrading Links
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  LinkToTradingView and Robinhood From InsiderTrading
// @author       You
// @match        http://insiderbuyingselling.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();
  AdjustWidth();
  MakeSortable();
})();

function MakeSortable() {
  $("tr:eq(1) td").click(function () {
    var table = $(this).parents('table').eq(0)
    var rows = table.find('tr:gt(1)').toArray().sort(comparer($(this).index()))
    this.asc = !this.asc
    if (!this.asc) {
      rows = rows.reverse()
    }
    for (var i = 0; i < rows.length; i++) {
      table.append(rows[i])
    }
  })
}

function comparer(index) {
  return function (a, b) {
    var valA = getCellValue(a, index).replace(",", ''),
      valB = getCellValue(b, index).replace(",", ''); //console.log(index);
    return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
  }
}

function getCellValue(row, index) {
  return $(row).children('td').eq(index).text()
}

function AdjustWidth() {
  $("#page").css("width", "100%")
}

function AddPortfolioLinks() {
  var all = $("table a[target!='_BLANK']")
  if (all.length === 0) {
    all = $("#body-table-portfolio td[title] a b")
  }
  all.each(function (x) {
    var stockName = $(this).html();
    var existing = $(this).parents("td").html();
    var finalLink = GenerateLinks(stockName, existing,false)

    $(this).parents("td").html(finalLink)
  })
}