Andrew Dolgov 6 months ago
commit
e0ef3cc4f1
2 changed files with 35 additions and 0 deletions
  1. 7 0
      README.md
  2. 28 0
      init.php

+ 7 - 0
README.md

@@ -0,0 +1,7 @@
+## Workaround for Chrome issue #945117
+
+https://discourse.tt-rss.org/t/android-article-load-very-slow-with-chrome-72-73/
+
+## Installation
+
+Git clone to /plugins.local/api_content_lang

+ 28 - 0
init.php

@@ -0,0 +1,28 @@
+<?php
+class Api_Content_Lang extends Plugin {
+	private $host;
+
+	function about() {
+		return array(1.0,
+			"Sets lang=zh to article content returned via API (Chrome issue workaround)",
+			"fox");
+	}
+
+	function init($host) {
+		$this->host = $host;
+
+		$host->add_hook($host::HOOK_RENDER_ARTICLE_API, $this);
+	}
+
+	function hook_render_article_api($row) {
+		$article = isset($row['headline']) ? $row['headline'] : $row['article'];
+
+		$article['content'] = "<div lang='zh'>" . $article['content'] . "</div>";
+
+		return $article;
+	}
+
+	function api_version() {
+		return 2;
+	}
+}