简体   繁体   English

Chrome扩展程序可修改Twitter的innerHTML

[英]Chrome Extension to modify innerHTML of Twitter

I am trying to make a chrome extension that changes the names of my twitter users as they appear on my feed. 我正在尝试创建一个Chrome扩展名,以更改Twitter用户在我的供稿中显示的名称。 When I try in the google chrome console to do: 当我尝试在Google Chrome浏览器控制台中执行以下操作时:

$("#fullname js-action-profile-name show-popup-with-id").html("Hello!"); $(“#fullname js-action-profile-name show-popup-with-id”)。html(“ Hello!”);

The result is just an empty array "[]". 结果只是一个空数组“ []”。

Also when I type: 另外当我键入:

document.getElementById("#fullname js-action-profile-name show-popup-with-id").html("Hello!"); document.getElementById(“#fullname js-action-profile-name show-popup-with-id”)。html(“ Hello!”);

I get the error: "Cannot set property of "html" of null". 我收到错误:“无法设置null的“ html”属性”。

Anyone know what I am doing wrong? 有人知道我在做什么错吗?

You would want to use something like this: 您可能想使用如下形式:

var twitterNames = $(".fullname.js-action-profile-name.show-popup-with-id");

Or something like this: 或类似这样的东西:

var twitterNames = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id");

Once you have the array of all the elements on the page you can index into the array to change them. 在页面上具有所有元素的数组之后,您可以索引到数组中以进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM