2013-07-31 14:58:56 +00:00
|
|
|
<?php
|
|
|
|
class Shorten_Expanded extends Plugin {
|
|
|
|
private $host;
|
|
|
|
|
|
|
|
function about() {
|
2021-03-01 09:11:42 +00:00
|
|
|
return array(null,
|
2013-07-31 14:58:56 +00:00
|
|
|
"Shorten overly long articles in CDM/expanded",
|
|
|
|
"fox");
|
|
|
|
}
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$this->host = $host;
|
|
|
|
|
2020-12-11 06:22:30 +00:00
|
|
|
$host->add_hook($host::HOOK_SANITIZE, $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// native lazy loading messes with plugin height calculation because images get loaded
|
|
|
|
// after headline is actually rendered (off screen) so we force disable it
|
|
|
|
function hook_sanitize($doc) {
|
|
|
|
$xpath = new DOMXPath($doc);
|
|
|
|
|
|
|
|
$entries = $xpath->query('(//*[@loading="lazy"])');
|
|
|
|
|
|
|
|
foreach ($entries as $entry) {
|
|
|
|
$entry->removeAttribute("loading");
|
|
|
|
}
|
|
|
|
|
|
|
|
return $doc;
|
2013-07-31 14:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_css() {
|
|
|
|
return file_get_contents(__DIR__ . "/init.css");
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_js() {
|
|
|
|
return file_get_contents(__DIR__ . "/init.js");
|
|
|
|
}
|
|
|
|
|
|
|
|
function api_version() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2020-12-11 06:22:30 +00:00
|
|
|
}
|