Skip to content

Instantly share code, notes, and snippets.

@Griever
Last active October 13, 2015 06:27
Show Gist options
  • Save Griever/4153100 to your computer and use it in GitHub Desktop.
Save Griever/4153100 to your computer and use it in GitHub Desktop.
plugins.click_to_play でブロックした YouTube の埋め込み動画にサムネイルをつける
clicktoplay.xml を chrome フォルダに保存。
Stylish で使う場合はフルパスに直すこと。
<?xml version="1.0"?>
<bindings id="aiueo"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="c2p_youtube">
<implementation>
<constructor><![CDATA[
var embed = this.parentNode;
var vid = embed.src.match(/\b[\w-]{11}\b/);
if (vid && vid[0]) {
embed.style.backgroundImage = "url(\"http://img.youtube.com/vi/" + vid[0] + "/mqdefault.jpg\")";
embed.style.backgroundPosition = "center center";
embed.style.backgroundRepeat = "no-repeat";
embed.style.backgroundSize = "cover";
embed.style.borderRadius = "12px";
}
]]></constructor>
</implementation>
</binding>
<binding id="c2p_youtube_iframe">
<implementation>
<constructor><![CDATA[
var embed = this.parentNode;
var vid = document.documentURI.match(/\b[\w-]{11}\b/);
if (vid && vid[0]) {
this.parentNode.style.backgroundImage = "url(\"http://img.youtube.com/vi/" + vid[0] + "/mqdefault.jpg\")";
embed.style.backgroundPosition = "center center";
embed.style.backgroundRepeat = "no-repeat";
embed.style.backgroundSize = "cover";
embed.style.borderRadius = "12px";
}
]]></constructor>
</implementation>
</binding>
</bindings>
@charset "utf-8";
@namespace url(http://www.w3.org/1999/xhtml);
embed[src*="youtube.com/v/"]:-moz-handler-clicktoplay > div {
-moz-binding: url("clicktoplay.xml#c2p_youtube") !important;
}
embed[src*="youtube.com/v/"]:-moz-handler-clicktoplay > *|vbox {
background-image: none !important;
}
@-moz-document url-prefix("http://www.youtube.com/embed/") {
embed:-moz-handler-clicktoplay > div {
-moz-binding: url("clicktoplay.xml#c2p_youtube_iframe") !important;
}
embed:-moz-handler-clicktoplay > *|vbox {
background-image: none !important;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment