Skip to content

Instantly share code, notes, and snippets.

@YungSang
Last active August 29, 2015 14:02
Show Gist options
  • Save YungSang/7acd58f084f1748d0e28 to your computer and use it in GitHub Desktop.
Save YungSang/7acd58f084f1748d0e28 to your computer and use it in GitHub Desktop.
[Deprecated] Taberareloo 用パッチ:YouTube からのポストを復活+関連動画からポストしても正常に動作するように修正
// ==Taberareloo==
// {
// "name" : "Fix extractor for YouTube"
// , "description" : "Fix extractor for YouTube"
// , "include" : ["background", "content"]
// , "match" : ["*://*.youtube.com/watch*"]
// , "version" : "0.1.3"
// , "downloadURL" : "https://gist.github.com/YungSang/7acd58f084f1748d0e28/raw/patch.extractor.youtube.extract.tbrl.js"
// }
// ==/Taberareloo==
(function() {
if (inContext('background')) {
var version = chrome.runtime.getManifest().version;
version = version.split('.');
if (version.length > 3) {
version.pop();
}
version = version.join('.');
if (semver.gte(version, '3.0.12')) {
setTimeout(function () {
Patches.uninstall(Patches['patch.extractor.youtube.extract.tbrl.js'], true);
}, 500);
return;
}
}
update(Extractors['Video - YouTube'], {
extract : function(ctx) {
// not use @rel="author"
// because official channel use banner image, can't get author text information by textContent.
var author_anchor = ctx.document.querySelector('#watch7-user-header .yt-user-name');
ctx.title = ctx.title.replace(/[\n\r\t]+/gm, ' ').trim();
var ps = {
type : 'video',
item : $X('id("watch7-content")/meta[@itemprop="name"]/@content')[0],
itemUrl : $X('id("watch7-content")/link[@itemprop="url"]/@href')[0],
author : author_anchor.textContent.trim(),
authorUrl : author_anchor.href.split('?')[0]
};
var canonical = $X('//link[@rel="canonical"]')[0];
if (canonical) {
canonical.parentNode.removeChild(canonical);
}
return ps;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment