我正在尝试使用 jQuery 和用户脚本更改表数据值,但它不起作用。这是我的代码:
// ==UserScript==
// @name My Fancy New Userscript
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @copyright 2012+, You
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
// Note, jQ replaces $ to avoid conflicts.
$('.last').html('111');
}
// load jQuery and execute the main function
addJQuery(main);
我究竟做错了什么?我在 Chrome 30.0.1599.69 上使用 Tampermonkey 扩展