From a8c6cd8b23855bd88a910bc1d4a38eea2f1cf65a Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 29 Nov 2019 02:16:16 +0800 Subject: [PATCH] feat: work with TT-RSS 19.8+ --- README.md | 6 ++---- init.php | 21 +++------------------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6966d80..9077783 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ ## What's this? -Tiny Tiny RSS plugin to remove sandbox attribute on some iframes in feeds, to make Tiny Tiny RSS work with some RSSHub routes - -- `player.bilibili.com` -- `bilibili.com` +Tiny Tiny RSS plugin to remove sandbox attribute on iframes in feeds, to make Tiny Tiny RSS work with some RSSHub routes ## Installation +1. Update TT-RSS to 19.8+ (19.8 is not included) 1. Checkout the directory into your TT-RSS root folder 1. `git clone https://github.com/DIYgod/ttrss-plugin-remove-iframe-sandbox.git plugins.local/remove_iframe_sandbox` 1. Enable `remove_iframe_sandbox` in your TT-RSS's `Preferences` -> `Plugins` diff --git a/init.php b/init.php index 583afd3..3534589 100644 --- a/init.php +++ b/init.php @@ -11,26 +11,11 @@ class Remove_Iframe_Sandbox extends Plugin { function init($host) { $this->host = $host; - $host->add_hook($host::HOOK_SANITIZE, $this); + $host->add_hook($host::HOOK_IFRAME_WHITELISTED, $this); } - function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) { - - $xpath = new DOMXpath($doc); - $entries = $xpath->query('//iframe'); - - foreach ($entries as $entry) { - $whitelist = array("player.bilibili.com", "bilibili.com"); - @$src = parse_url($entry->getAttribute("src"), PHP_URL_HOST); - if ($src) { - foreach ($whitelist as $w) { - if ($src == $w || $src == "www.$w") - $entry->removeAttribute("sandbox"); - } - } - } - - return array($doc, $allowed_elements, $disallowed_attributes); + function hook_iframe_whitelisted($src) { + return true; } function api_version() {