How I did it
The extension is very easy, it executes a GET request to the xkcd website, gets the content of the index page and returns it. What I used to do, for a matter of simplicity, was getting the content, paste it in an hidden div, get the image of the comic of the day (through a getElementById call) and put it in a visible div.
The Problem
What one would expect is that the Google Chrome popup page of the extension notice the change of content and resize itself to fit the new content. But this doesn't happen. The popup page remains as small as it can get without styles, or of a fixed with/height if specified in the css file. I didn't wanted to have a fixed width/height as comics usually have not a fixed size (sometimes they are as small as a strip, sometimes they are quite big).
Since the popup extension doesn't resize, I though about resizing it using JavaScript:
var width = document.getElementById("comic").offsetWidth + 10; var height = document.getElementById("comic").offsetHeight + 10; //[...] document.body.style.width = ""+width; document.body.style.height = ""+height; document.getElementsByTagName("html")[0].style.width = ""+width; document.getElementsByTagName("html")[0].style.height = ""+height;
(notice that I get the width and the height of the image and add a small offset to make it visually finer). The fact is that this approach wasn't working either. When opening the extension, one would see it flicker: first a frame of the correct size, and then a resize to the default 10 by 10 pixel frame.
The Solution
The solution was quite simple, but without somebody mentioning it on StackOverflow I would be still stuck. The fact is that the popup of the Chrome Extensions don't resize if there is a hidden element in the HTML tree. That is, basically the whole page I was hiding was preventing me to resize the popup frame. So the solution is:
document.getElementById("hiddenDiv").innerHTML = "";
And that solved every problem. The frame now is the correct size and I can read every two/three days the new xkcd comic.
Hi,
ReplyDeleteI was having the same problem.
There is a simple solution to this too.
You need to add
to the beginning of your popup code. :)
Src: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/AHPZo_yoNFg
Someone has already a solution for this one? .. I have been trying by using only one resizable textarea element in the popup...but, chrome doesn't resize the popup's height. However, it resizes the width.
ReplyDeleteDenizli
ReplyDeleteAnkara
Antep
Bursa
Eskişehir
İİ2H
görüntülü.show
ReplyDeletewhatsapp ücretli show
WD8YH
E2D07
ReplyDeleteSiirt Evden Eve Nakliyat
Şırnak Evden Eve Nakliyat
Bursa Evden Eve Nakliyat
Osmaniye Evden Eve Nakliyat
Kars Evden Eve Nakliyat
6D1C0
ReplyDeleteYenimahalle Parke Ustası
Kütahya Parça Eşya Taşıma
Erzincan Parça Eşya Taşıma
Muğla Şehir İçi Nakliyat
Kırklareli Şehirler Arası Nakliyat
Bitmex Güvenilir mi
Sivas Şehir İçi Nakliyat
Artvin Lojistik
Rize Şehirler Arası Nakliyat
09DB8
ReplyDeleteErzincan Şehir İçi Nakliyat
Düzce Evden Eve Nakliyat
Artvin Şehir İçi Nakliyat
Bayburt Evden Eve Nakliyat
Gölbaşı Fayans Ustası
Bingöl Evden Eve Nakliyat
Trabzon Evden Eve Nakliyat
Poloniex Güvenilir mi
Konya Evden Eve Nakliyat
ABB3A
ReplyDeletekastamonu parasız sohbet
Ordu Ücretsiz Sohbet Siteleri
bolu görüntülü sohbet ücretsiz
denizli canlı sohbet uygulamaları
Muğla Bedava Görüntülü Sohbet
isparta kadınlarla sohbet et
Antep Canlı Görüntülü Sohbet Uygulamaları
batman sesli sohbet siteler
canli sohbet chat
2D3A5
ReplyDeleteSnapchat Takipçi Hilesi
Okex Borsası Güvenilir mi
Binance Borsası Güvenilir mi
Likee App Beğeni Hilesi
Tumblr Beğeni Hilesi
Kripto Para Nasıl Oynanır
Parasız Görüntülü Sohbet
Bitcoin Nasıl Çıkarılır
Azero Coin Hangi Borsada
63A86
ReplyDeleteCoin Nasıl Oynanır
Facebook Sayfa Beğeni Satın Al
Coin Madenciliği Nasıl Yapılır
Onlyfans Takipçi Hilesi
Coin Nasıl Çıkarılır
Instagram Beğeni Hilesi
Twitch Takipçi Satın Al
Likee App Beğeni Satın Al
Luffy Coin Hangi Borsada
E808F
ReplyDeleteReferans Kimliği Nedir
Bitcoin Para Kazanma
Apenft Coin Hangi Borsada
Mefa Coin Hangi Borsada
Nexa Coin Hangi Borsada
Bitcoin Kazanma Siteleri
Meta Coin Hangi Borsada
Tumblr Takipçi Satın Al
Coin Oynama
YHJVYHKM
ReplyDeleteشركة مكافحة حشرات بالاحساء
gthghjkngfkhfjkg
ReplyDeleteترولى نولن