bb0d2bf675
Some articles (especially the recent year-in-review ones) include a Youtube video. The server-side rendered articles do not include the Youtube iframe, but they do have a script that looks like <script type="text/javascript" data-reactid="6"> window.__APOLLO_STATE__ = { ... youtube_id: "9uASADiYe_8", We add a reformatting function that tries to detect obvious JavaScript code that has a field or variable called youtube_id that has an 11-character double-quoted value, and adds the referenced Youtube videos in the beginning of the article. This is slightly more general than needed for Quanta, in the hope that it could be useful for similar sites.
36 lines
1.7 KiB
Go
36 lines
1.7 KiB
Go
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
|
// Use of this source code is governed by the Apache 2.0
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package rewrite // import "miniflux.app/reader/rewrite"
|
|
|
|
// List of predefined rewrite rules (alphabetically sorted)
|
|
// Available rules: "add_image_title", "add_youtube_video"
|
|
// domain => rule name
|
|
var predefinedRules = map[string]string{
|
|
"abstrusegoose.com": "add_image_title",
|
|
"amazingsuperpowers.com": "add_image_title",
|
|
"cowbirdsinlove.com": "add_image_title",
|
|
"drawingboardcomic.com": "add_image_title",
|
|
"exocomics.com": "add_image_title",
|
|
"framatube.org": "nl2br,convert_text_link",
|
|
"happletea.com": "add_image_title",
|
|
"imogenquest.net": "add_image_title",
|
|
"invidio.us": "add_invidious_video",
|
|
"lukesurl.com": "add_image_title",
|
|
"medium.com": "fix_medium_images",
|
|
"mercworks.net": "add_image_title",
|
|
"monkeyuser.com": "add_image_title",
|
|
"mrlovenstein.com": "add_image_title",
|
|
"nedroid.com": "add_image_title",
|
|
"oglaf.com": "add_image_title",
|
|
"optipess.com": "add_image_title",
|
|
"peebleslab.com": "add_image_title",
|
|
"quantamagazine.org": `add_youtube_video_from_id, remove("h6:not(.byline,.post__title__kicker), #comments, .next-post__content, .footer__section, figure .outer--content, script")`,
|
|
"sentfromthemoon.com": "add_image_title",
|
|
"thedoghousediaries.com": "add_image_title",
|
|
"treelobsters.com": "add_image_title",
|
|
"www.qwantz.com": "add_image_title,add_mailto_subject",
|
|
"xkcd.com": "add_image_title",
|
|
"youtube.com": "add_youtube_video",
|
|
}
|