如何通过js注入实现我想要的功能?

提问:

据说可以通过注入JS实现某些网站没有的功能。

我想要在这段代码内直接显示EuropeOdds()内的数值,或者把这个链接改成按钮,点击复制EuropeOdds()内的值,再或者干脆新增一个按钮来获取数值都可以。

根据作者提供的代码修改如下:

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>js注入问题解答 xinbiancheng.cn</title>
</head>

<body>
  <table>
    <tr align="center" id="tr1_1974559" bgcolor="#F0F0F0" index="2"
      style="height: 18px; background-color: rgb(240, 240, 240);"
      odds="1974559,10206252,0,0.63,1.23,101426348,4.95,1.30,6.60,10109014,2.50,1.75,0.37,2,0,0,0">
      <td><input type="checkbox" class="inp" id="chk_1974559"></td>
      <td bgcolor="#6C6C00" style="color:white;"><a href="http://zq.win007.com/cn/cupmatch.aspx?sclassid=196"
          target="_blank" title="进入资料库">
          <font color="white">保杯</font>
        </a></td>
      <td align="center" id="mt_1974559">18:00</td>
      <td align="center" id="time_1974559" class="td_status">81<img src="bf_img/in.gif" border="0"></td>
      <td align="right"><span id="horder_1974559"></span><a id="yellow1_1974559"><img src="bf_img/yellow1.gif"></a><a
          id="redcard1_1974559"></a><a id="team1_1974559" href="javascript:"
          onclick="showTeamPanlu(1974559)">普罗夫迪夫博特夫</a>
      </td>
      <td aloc="2" onclick="showgoallist(1974559)" class="td_score" onmouseover="showdetail(this,event,3)"
        onmouseout="hiddendetail()">1-1</td>
      <td align="left"><a id="team2_1974559" href="javascript:" onclick="showTeamPanlu(1974559)">CSKA索菲亚</a><a
          id="redcard2_1974559"></a><a id="yellow2_1974559"><img src="bf_img/yellow1.gif"></a><span
          id="gorder_1974559"></span></td>
      <td style="cursor:pointer;"><span class="td_halfB" aloc="2" onmouseover="showSBCorner(this,event)"
          onmouseout="hiddenSbCorner()" style="display:none">3-2</span><br><span class="td_halfR" aloc="2"
          onmouseover="showpaulu(this,event,3)" onmouseout="hiddendetail()" style="color: red;">0-1</span></td>
      <td><a style="display:block;" href="javascript:void(0)" onclick="openFlash(1974559)" title="现场分析"><img
            src="images/ant/show_info.png"></a></td>
      <td class="oddss" width="4%">
        <div class="odds4"><span class="up">0.63</span></div>
        <div class="odds4">1.75</div>
      </td>
      <td width="10%" id="pk_1974559" class="oddss" goal="0.25,1.35,0.56,101426348,3.20" onclick="AsianOdds(1974559)"
        style="cursor:pointer;" aloc="2" onmouseover="showOddsDetail(this,event)" onmouseout="hiddenSbDetail()">
        <div class="odds4">平手</div>
        <div class="odds4">2.5</div>
      </td>
      <td class="oddss" width="4%">
        <div class="odds4"><span class="down">1.23</span></div>
        <div class="odds4">0.37</div>
      </td>
      <td class="zd" onclick="showgoallist(1974559)"><span><img src="image/zd2.gif" height="10" width="10"
            title="正在走地"></span><span><img title="有走地" src="image/zds.png"></span></td>
      <td class="icons2"><a href="javascript:" onclick="analysis(1974559)" title="数据分析">析</a> <a style="cursor:pointer;"
          href="javascript:" onclick="AsianOdds(1974559);" title="亚指指数">亚</a> <a style="cursor:pointer;"
          href="javascript:" onclick="TotalOdds(1974559);" title="大小指数">大</a> <a href="javascript:"
          onclick="EuropeOdds(this,1974559);" title="欧指指数">欧</a><a href="javascript:advices(1974559)"><img
            src="image/g.gif" title="赛事推荐"></a></td>
      <td><a href="javascript:addConcern(2,14);" title="添加置顶"><img src="image/unTop.png"></a></td>
    </tr>
  </table>
  <script>
    function EuropeOdds(th, id) {
      th.innerHTML = id;
      console.log(id)
    }
  </script>
</body>

</html>

当点击“欧”链接时,通过 js , ID自动的被渲染出来。