commit 146278196035cd47d271bbe6235ea4221e49bb8f Author: DIYgod Date: Tue Nov 26 17:52:11 2019 +0800 feat: init diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..07d58a6 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d173aaf --- /dev/null +++ b/README.md @@ -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.
+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) diff --git a/remove_iframe_sandbox/init.php b/remove_iframe_sandbox/init.php new file mode 100644 index 0000000..583afd3 --- /dev/null +++ b/remove_iframe_sandbox/init.php @@ -0,0 +1,41 @@ +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; + } + +} +?> \ No newline at end of file