Charts on Twitter CashTags

Add link for charts in Twitter CashTags

目前为 2021-01-20 提交的版本。查看 最新版本

// ==UserScript==
// @name         Charts on Twitter CashTags
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add link for charts in Twitter CashTags
// @author       @ozero
// @match        https://twitter.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // insert links for chart service
    let decorate = (anchors) => {

        for (let i in anchors){
            let txt = anchors[i].innerText;
            if(txt == ""){continue;}
            let href = anchors[i].href + "";
            if(href == ""){continue;}
            //
            if(href.substring(href.length - 13) == "cashtag_click"){
                if( anchors[i].getAttribute("data-decorate") == "done" ){
                    continue;
                }

                let symbol = txt.replace("$","");
                let links = [
                    '$', symbol, '</a><span style="font-size:80%;">[',
                    '<a target="_blank" href="http://stockcharts.com/h-sc/ui?s=', symbol, '">SC</a>',
                    ' , <a target="_blank" href="http://finance.yahoo.com/q?s=', symbol, '">Y!</a>',
                    ']</span>'
                ].join("");
                anchors[i].innerHTML = links;
                anchors[i].dataset.decorate = "done";
            }
            continue;
        }
    }

    //check and insert periodically (2sec)
    let scan_for_cashtags = () =>{
        window.setTimeout(function(){
            let a_list = document.getElementsByTagName("a");
            decorate(a_list);
            scan_for_cashtags();
        }, 2000);
    }

    //bootstrap
    scan_for_cashtags();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址