mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-04 04:47:52 +01:00
Constrain the height of iframes that are percent-sized relative to the document body to 50% of the viewport width
This commit is contained in:
parent
72ce1e3f00
commit
6d7cc4d386
@ -25,6 +25,22 @@ function stripStyles() {
|
|||||||
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => stripStylesFromElement(element, ["color", "background", "font", "max-width", "max-height", "position"]));
|
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => stripStylesFromElement(element, ["color", "background", "font", "max-width", "max-height", "position"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constrain the height of iframes whose heights are a percent of the document body to be at most
|
||||||
|
// 50% of the viewport width.
|
||||||
|
function constrainBodyRelativeIframes() {
|
||||||
|
let iframes = document.getElementsByTagName("iframe");
|
||||||
|
|
||||||
|
for (iframe of iframes) {
|
||||||
|
if (iframe.offsetParent === document.body) {
|
||||||
|
let heightAttribute = iframe.style.height;
|
||||||
|
|
||||||
|
if (/^\d+%$/.test(heightAttribute)) {
|
||||||
|
iframe.classList.add("nnw-constrained");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert all Feedbin proxy images to be used as src, otherwise change image locations to be absolute if not already
|
// Convert all Feedbin proxy images to be used as src, otherwise change image locations to be absolute if not already
|
||||||
function convertImgSrc() {
|
function convertImgSrc() {
|
||||||
document.querySelectorAll("img").forEach(element => {
|
document.querySelectorAll("img").forEach(element => {
|
||||||
@ -137,6 +153,7 @@ function processPage() {
|
|||||||
wrapTables();
|
wrapTables();
|
||||||
inlineVideos();
|
inlineVideos();
|
||||||
stripStyles();
|
stripStyles();
|
||||||
|
constrainBodyRelativeIframes();
|
||||||
convertImgSrc();
|
convertImgSrc();
|
||||||
flattenPreElements();
|
flattenPreElements();
|
||||||
styleLocalFootnotes();
|
styleLocalFootnotes();
|
||||||
|
@ -204,6 +204,10 @@ iframe {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iframe.nnw-constrained {
|
||||||
|
max-height: 50vw;
|
||||||
|
}
|
||||||
|
|
||||||
figure {
|
figure {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user