Created
August 17, 2010 11:39
-
-
Save anekos/529523 to your computer and use it in GitHub Desktop.
見た目を変え難い nsIAlertService の代用。xul ファイルいらず。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xml = | |
<window id="twitt-popup" | |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" | |
xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
pack="start" | |
ondblclick="window.close()"> | |
<box id="dialog" style="padding: 10px; border: 2px solid #7B969C;"> | |
<hbox align="center" pack="center"> | |
<image id="profile-image"/> | |
</hbox> | |
<vbox> | |
<label id="screen-name" style="font-size: 20px; font-weight: bold;"/> | |
<description id="text" style="font-size: 14px; max-width: 200px !important"/> | |
</vbox> | |
</box> | |
<script type="application/javascript"><![CDATA[ | |
function set (name, attr, value) | |
document.getElementById(name)[attr] = value; | |
let opts = window.arguments[0]; | |
set('profile-image', 'src', 'http://snca.net/blogfiles/devcat-face-red-eye-animation-optimized.gif'); | |
set('screen-name', 'textContent', opts.screenName + opts.rand()); | |
set('text', 'textContent', opts.text); | |
// ちらっと左上に出るのを防止 | |
window.moveTo(-10000, -10000); | |
let h = setInterval(function() { | |
let x = screen.availLeft + screen.availWidth - window.outerWidth; | |
let y = screen.availTop + screen.availHeight - window.outerHeight; | |
window.moveTo(x, y); | |
if (window.outerWidth > 100 && window.outerHeight > 100) | |
clearInterval(h); | |
}, 0); | |
]]></script> | |
</window>; | |
function rand () | |
parseInt(Math.random() * 100, 10); | |
let uri = 'data:application/vnd.mozilla.xul+xml;base64,' + btoa(xmlst + xml.toString()); | |
setTimeout( | |
function(){ | |
let win = | |
window.openDialog( | |
uri, | |
null, //'anekos-alert-window', // 指定すれば多重にポップアップしないかも | |
'chrome,dialog=yes,titlebar=no,popup=yes', | |
{ | |
screenName: 'anekos', | |
text: '\u3075\u304A\u304A\u304A!!\n\u304A\u307E\u3048\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082\u3082 Vimperator \u4F7F\u3044\u306B\u3057\u3066\u3084\u308D\u3046\u304B\uFF01', | |
rand: rand | |
} | |
); | |
setTimeout(function() win.close(), 5000); | |
}, | |
0 | |
); | |
// chrome://global/content/alerts/alert.js | |
//view-source:chrome://global/content/alerts/alert.xul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment