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

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

目前為 2024-02-16 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/487476/1328526/%5BGC%20%7C%20Library%5D%20-%20Highlight%20and%20sort%2015%20NP%20stocks.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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';
                });
            });
        }
    }