Skip to content

Instantly share code, notes, and snippets.

@ailispaw
Last active January 6, 2020 13:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ailispaw/0b8eef48ffa07a9ef56a to your computer and use it in GitHub Desktop.
Save ailispaw/0b8eef48ffa07a9ef56a to your computer and use it in GitHub Desktop.
Fix extractor for YouTube
// ==Taberareloo==
// {
// "name" : "Fix extractor for YouTube"
// , "description" : "Fix extractor for YouTube"
// , "include" : ["content"]
// , "match" : ["*://*.youtube.com/watch*"]
// , "version" : "0.2.0"
// , "downloadURL" : "https://gist.githubusercontent.com/ailispaw/0b8eef48ffa07a9ef56a/raw/patch.extractor.youtube.extract.tbrl.js"
// }
// ==/Taberareloo==
(function() {
addAround(Extractors['Video - YouTube'], 'extract', function (proceed, args, target, methodName) {
var ctx = args[0];
// not use @rel="author"
// because official channel use banner image, can't get author text information by textContent.
var author = ctx.document.querySelector('#owner-name a');
var title = ctx.document.querySelector('#player a.ytp-title-link');
ctx.title = ctx.title.replace(/[\n\r\t]+/gm, ' ').trim();
var ps = {
type : 'video',
item : title.textContent.trim(),
itemUrl : title.href,
author : author.textContent.trim(),
authorUrl : author.href
};
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