【发布时间】:2012-02-25 20:37:41
【问题描述】:
我正在尝试创建一个用户脚本,它会自动将当前网址的二维码图像添加到 youtube 视频页面上的“共享”菜单中。
我对 JavaScript、UserScript、HTML 等几乎一无所知。 但是,这是我目前所拥有的:
// ==UserScript==
// @name Youtube QR ShareLink
// @description Displays QR of youtube URL
// @version 0.1
// @match http://www.youtube.com/watch*
// @match https://www.youtube.com/?*
// @match http://www.youtube.com/?*
// @match https://www.youtube.com/watch*
// @include http://www.youtube.com/?*
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/?*
// @include https://www.youtube.com/watch*
// ==/UserScript==
(function () {
var shareDiv = document.getElementById('share-option-container ytg-box');
var qrIMG = 'http://chart.googleapis.com/chart?chl=' + window.location.href + '&chld=M%7C0&cht=qr&chs=125x125';
var img = document.createElement('qrcode');
img.src=qrIMG;
img.width=125;
img.height=125;
shareDiv.appendChild(img);
}());
不出所料,它不起作用。 谁能告诉我我做错了什么?
谢谢!
【问题讨论】:
-
这里没有意义:
'share-option-container ytg-box'id不能有空格。
标签: javascript youtube share qr-code userscripts