[GC | Library] - Highlight and sort 15 NP stocks

Automatically identifies cheapest buyable stocks for easily selecting a stock to purchase.

Este script no debería instalarse directamente. Es una biblioteca que utilizan otros scripts mediante la meta-directiva de inclusión // @require https://update.greasyfork.org/scripts/487476/1328526/%5BGC%20%7C%20Library%5D%20-%20Highlight%20and%20sort%2015%20NP%20stocks.js

function highlightRows() {
        var table = document.querySelector('table[border="1"]');

        if (!table) {
            console.log("Table not found on this page.");
            return;
        }

        var rows = Array.from(table.querySelectorAll('tr'));

        // Display buyable stocks
        var curr15Rows = [];

        rows.forEach(function(row) {
            var cells = row.querySelectorAll('td');
            if (cells.length >= 6) {
                var currCell = cells[5];
                if (currCell.textContent.trim() === "15") {
                    curr15Rows.push(row);
                }
            }
        });

        if (curr15Rows.length === 0) {
            // Display a message if there are no buyable stocks
            var messageDiv = document.createElement('div');
            messageDiv.textContent = "😭 There are no buyable stocks at this time.";
            messageDiv.style.fontSize = '24px';
            messageDiv.style.textAlign = 'center';
            table.parentNode.insertBefore(messageDiv, table);
        } else {
            curr15Rows.forEach(function(row) {
                row.parentNode.removeChild(row);
                table.insertBefore(row, table.firstChild);

                var cells = row.querySelectorAll('td');
                cells.forEach(function(cell) {
                    cell.style.backgroundColor = 'yellow';
                });
            });
        }
    }