feat: work with TT-RSS 19.8+
This commit is contained in:
parent
d22e549a21
commit
a8c6cd8b23
|
|
@ -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`
|
||||
|
|
|
|||
21
init.php
21
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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue