「TheBONEZ」公式HP
$(function(){
const iframeWithoutClassArr = []
const iframeWithoutClassInnerHeightArr = []
const iframeWithoutClassOuterHeightArr = []
const iframeElmAll = document.querySelectorAll('.articleRelatedInfo iframe')
for(const iframeElm of iframeElmAll ) {
if(iframeElm.classList.length === 0) {
iframeWithoutClassArr.push(iframeElm)
iframeWithoutClassOuterHeightArr.push(iframeElm.height)
}
}
const iframeWithoutClassRemoveEqualOuterHeightArr = [...new Set(iframeWithoutClassOuterHeightArr)]
$(window).on('message', function(e){
if(typeof(e.originalEvent.data) === "string" && e.originalEvent.data.includes('height')) {
const iframeDatas = JSON.parse(e.originalEvent.data)
iframeWithoutClassInnerHeightArr.push(iframeDatas.details.height)
const iframeWithoutClassRemoveEqualInnerHeightArr = [...new Set(iframeWithoutClassInnerHeightArr)]
if(iframeWithoutClassRemoveEqualOuterHeightArr.length > iframeWithoutClassRemoveEqualInnerHeightArr.length) {
return
}
for(let [index, iframeWithoutClass] of iframeWithoutClassArr.entries()) {
const iframeWithoutClassHeight = Number(iframeWithoutClass.height)
let equalHeight = false
for(const iframeInnerHeight of iframeWithoutClassRemoveEqualInnerHeightArr) {
if(index === 0 && iframeInnerHeight === iframeWithoutClassHeight){
equalHeight = true
}
}
if(equalHeight) {continue}
iframeWithoutClass.height =
iframeWithoutClassRemoveEqualInnerHeightArr[index] ?
iframeWithoutClassRemoveEqualInnerHeightArr[index] : iframeWithoutClassInnerHeightArr[index]
}
}
});
});