Last active
January 6, 2020 13:10
-
-
Save ailispaw/0b8eef48ffa07a9ef56a to your computer and use it in GitHub Desktop.
Fix extractor for YouTube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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