feat: init
This commit is contained in:
commit
1462781960
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 DIYgod
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# ttrss-plugin-remove-iframe-sandbox
|
||||
|
||||
## 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`
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the folder `remove_iframe_sandbox`
|
||||
1. Move the folder `remove_iframe_sandbox` to your TT-RSS plugins directory
|
||||
1. Enable `remove_iframe_sandbox` in your TT-RSS's `Preferences` -> `Plugins`
|
||||
|
||||
or
|
||||
|
||||
Use [Awesome-TTRSS](https://github.com/HenryQW/Awesome-TTRSS)
|
||||
|
||||
## Author
|
||||
|
||||
**ttrss-plugin-remove-iframe-sandbox** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
|
||||
Authored and maintained by DIYgod.
|
||||
|
||||
> Blog [@DIYgod](https://diygod.me) · GitHub [@DIYgod](https://github.com/DIYgod) · Twitter [@DIYgod](https://twitter.com/DIYgod) · Telegram Channel [@awesomeDIYgod](https://t.me/awesomeDIYgod)
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
class Remove_Iframe_Sandbox extends Plugin {
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"Remove sandbox attribute on some iframes in feeds (bilibili)",
|
||||
"https://github.com/DIYgod/ttrss-plugin-remove-iframe-sandbox");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->host = $host;
|
||||
|
||||
$host->add_hook($host::HOOK_SANITIZE, $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 api_version() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue