bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:2323回复:7

请高手改一下这个脚本,怎样才可以限制他最大化

楼主#
更多 发布于:2010-03-03 16:55
userChromeJS
http://userchromejs.mozdev.org/

在配置文件夹的chrome目录里,编辑userChrome.js,在最后加上一行

userChrome.import("*", "UChrm");

保存,退出,把下面这个代码保存成一个.js脚本,这个应该会把,新建TXT文件……放到在配置文件夹的chrome目录里,重启FX即可

(function(){const B=document.getElementById("main-window");if(B){window.maximize();const A=document.getElementById("window-controls");A.setAttribute("fullscreencontrol","false");A.setAttribute("hidden","false");B.setAttribute("hidechrome","true");while(STATE_NORMAL!==window.windowState){window.restore()}window.moveTo(screen.availLeft,screen.availTop);window.resizeTo(screen.availWidth,screen.availHeight);document.getAnonymousElementByAttribute(document.getElementById("status-bar"),"class","statusbar-resizerpanel").setAttribute("hidden","true")}})();

目前这个脚本有一个bug,就是当有窗口弹出的时候,建立了一个新标签,就最大化了,菜单也给隐藏了,然后鼠标上去后菜单就出来了,离开就又隐藏了,怎样屏蔽一下这个隐藏,就是不最大化,不隐藏菜单和工具栏,感谢先,请高手出手修正一下,这个脚本和不错的
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
1楼#
发布于:2010-03-03 16:55
就是要禁止最大化,点击一下最大化那个按钮,他就自动隐藏了菜单栏和工具栏
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
2楼#
发布于:2010-03-03 16:55
请高手出手,启动的时候布满屏幕,然后就是中间不管弹出啥窗口,都最大化失效,不允许最大化了,请帮助!
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
3楼#
发布于:2010-03-03 16:55
(function(){const B=document.getElementById("main-window");
if(B){window.maximize();const A=document.getElementById("window-controls");A.setAttribute("fullscreencontrol","false");
A.setAttribute("hidden","false");
B.setAttribute("hidechrome","true");
while(STATE_NORMAL!==window.windowState){window.restore()}window.moveTo(screen.availLeft,screen.availTop);window.resizeTo (screen.availWidth,screen.availHeight);
document.getAnonymousElementByAttribute(document.getElementById("status-bar"),"class","statusbar-resizerpanel").setAttribute("hidden","true")}})();
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
4楼#
发布于:2010-03-03 16:55
请哪位大师帮忙修改一下,好像还是不行
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
5楼#
发布于:2010-03-03 16:55
const SHOW_GECKO_VERSION = true //show gecko version on title when start
const TITLE_ALIGN = 'right' //set title Align
const MAXTHON_LIKE = true //toggle maxthon like style
const MAXTHON_LIKE_TITLE_ALIGN = 'left' //set maxthon like style title Align
const USE_TAB_TITLE = false //using tabs title as titlebar title ^^
const DEFALUT_TITLE = '' //the defaule app name for title display
const DISPLAY_TITLE = true //if titlebar display
const LOGO_PADDING = 2 //Smaller logo size
const NO_TITLE = false //display webpage title on titlebar or not
//get app window last position
hcPrefs = Components.classes['@mozilla.org/preferences-service;1']
                      .getService(Components.interfaces.nsIPrefService)
                      .getBranch('');
if (!hcPrefs.prefHasUserValue('wTop')) hcPrefs.setIntPref('wTop',screen.availTop+screen.availHeight/6);
if (!hcPrefs.prefHasUserValue('wLeft')) hcPrefs.setIntPref('wLeft',screen.availLeft+screen.availWidth/6);
if (!hcPrefs.prefHasUserValue('wHeight')) hcPrefs.setIntPref('wHeight',screen.availHeight/1.5);
if (!hcPrefs.prefHasUserValue('wWidth')) hcPrefs.setIntPref('wWidth',screen.availWidth/1.5);
if (!hcPrefs.prefHasUserValue('wFullscreen')) hcPrefs.setBoolPref('wFullscreen',true);

wLeft = hcPrefs.getIntPref('wLeft');
wTop = hcPrefs.getIntPref('wTop');
wWidth = hcPrefs.getIntPref('wWidth');
wHeight = hcPrefs.getIntPref('wHeight');

var mWindow = document.getElementById('main-window');
var mChromehided = true;
var curTitle = DEFALUT_TITLE

var hideCaption={
runOnce:true,

init:function(){
if(mWindow)
{
mChromehided = !(mWindow.getAttribute('hidechrome') == 'false');
   Class = <!-- e --><a href="mailto:'@mozilla.org">'@mozilla.org</a><!-- e -->/preferences-service;1';
   gPref = Components.classes[Class].getService(
       Components.interfaces.nsIPrefService).
       getBranch('extensions.');

var tMenu = document.getElementById('toolbar-menubar');
var tMenu1 = document.getElementById('nav-bar');
//fix something for version 3.0
try
{
tMenu.childNodes[1].setAttribute('hidden','true');
tMenu.childNodes[2].setAttribute('hidden','true');
}
catch(e) {};

//show Firefox Logo
var appLogo = document.createElement('hbox');
appLogo.setAttribute('id','hc-appLogo');
appLogo.setAttribute('hidden','true');
var appLogoimg =document.createElement('image');
appLogoimg.setAttribute('id','hc-appLogoimg');
appLogoimg.setAttribute('src','chrome://branding/content/icon48.png');
appLogoimg.setAttribute('style', 'max-height:20px ;max-width:20px;padding:' + LOGO_PADDING + 'px !important;');
appLogoimg.setAttribute('ondblclick','BrowserTryToCloseWindow();');
appLogo.appendChild(appLogoimg);
tMenu.insertBefore(appLogo,document.getElementById('menubar-items'));

//show title
var tBox = document.createElement('hbox');
tBox.setAttribute('id','hc-title');
tBox.setAttribute('align','center');
tBox.setAttribute('flex','1');

var tSpace = document.createElement('hbox');
tSpace.setAttribute('id','hc-space');
tSpace.setAttribute('hidden','true');
tSpace.setAttribute('flex','1');

var tLabel =document.createElement('label');
tLabel.setAttribute('id','contents-title');
tLabel.setAttribute('crop','right');
tLabel.setAttribute('flex','1');
if (DISPLAY_TITLE == false) tLabel.setAttribute('hidden','true');

if (DEFALUT_TITLE == '')
curTitle = mWindow.getAttribute('title');
var vTitle =curTitle;

//show ver in title
if (SHOW_GECKO_VERSION)
{
vTitle = vTitle + ' ' + navigator.product +'/' + navigator.productSub
};
tLabel.setAttribute('value',vTitle);
tBox.appendChild(tLabel);

//toggle maxthon style
if (!MAXTHON_LIKE)
{
//My faves
tLabel.setAttribute('style', 'text-align:' + TITLE_ALIGN + ';font-weight: bold;');
tMenu.appendChild(tBox);
}
else
{
//Maxthon Like
tLabel.setAttribute('style', 'text-align:' + MAXTHON_LIKE_TITLE_ALIGN + ';font-weight: bold;');
tMenu.insertBefore(tBox,document.getElementById('menubar-items'));
}
tMenu.appendChild(tSpace);

//show control buttons
document.getElementById('minimize-button').setAttribute('hidden','true');
document.getElementById('close-button').setAttribute('hidden','true');
//document.getElementById('close-button').setAttribute('oncommand','goQuitApplication()');
var separator=document.createElement('toolbarseparator');
separator.setAttribute('class','chromeclass-toolbar-additional');
tMenu1.appendChild(separator);
tMenu1.appendChild(document.getElementById('minimize-button'));
tMenu1.appendChild(document.getElementById('restore-button'));
tMenu1.appendChild(document.getElementById('close-button'));
document.getElementById('restore-button').setAttribute('oncommand','hideCaption.BrowserFullScreen();');

if (hcPrefs.getBoolPref('wFullscreen') ||(STATE_MAXIMIZED == window.windowState))
{
hideCaption.BrowserFullScreen();
}
else
{
hideCaption.runOnce = false;
document.getElementById('hc-title').setAttribute('hidden','true');
document.getElementById('hc-space').setAttribute('hidden','false');
};

document.getAnonymousElementByAttribute(document.getElementById('status-bar'),'class','statusbar-resizerpanel').setAttribute('hidden','true')

// Listeners
if (!NO_TITLE) {
gBrowser.selectedTab.addEventListener('DOMAttrModified', hideCaption.onTabOpen, false);
gBrowser.tabContainer.addEventListener('TabOpen', hideCaption.onTabOpen, false);
gBrowser.tabContainer.addEventListener('TabClose', hideCaption.onTabClose, false);
}
window.addEventListener('unload', function() { hideCaption.keepWinPos() }, false);
}
},

BrowserFullScreen:function()
{
mChromehided = (mWindow.getAttribute('hidechrome') == 'true');

if (STATE_MAXIMIZED == window.windowState)
{
dump('3' + '\n');
while(STATE_NORMAL!=window.windowState){window.restore()};
if (!mChromehided)
{
//saveWinPos();
//keepWinPos();
//window.resizeTo(0,0);
hideCaption.maxisize();
}
}
else
{
if (mChromehided)
{
dump('1' + '\n');
hideCaption.restore();
if (hideCaption.runOnce == true)
{
window.maximize();
window.restore();
hideCaption.runOnce = false;
};
}
else
{
dump('2' + '\n');
if (!hcPrefs.getBoolPref('wFullscreen'))
{
hideCaption.saveWinPos();
hideCaption.keepWinPos();
};
hideCaption.maxisize();
}
}
},

changeTitle:function(event)
{
if (event.target !=gBrowser.selectedTab) return;
var newTitle='';

if (event.attrName == 'label')
{
newTitle = event.newValue;
if (USE_TAB_TITLE == false)
newTitle = newTitle + ' - ' + curTitle;
document.getElementById('contents-title').setAttribute('value',newTitle);
return;
}
else if ((event.attrName == 'selected') &&(event.newValue == 'true'))
{
var tab = gBrowser.mTabContainer.childNodes[gBrowser.mTabContainer.selectedIndex];
newTitle=tab.getAttribute('label');
if (USE_TAB_TITLE == false)
newTitle = newTitle + ' - ' +curTitle;
document.getElementById('contents-title').setAttribute('value',newTitle);
return;
}
},

onTabOpen:function(event){
event.target.addEventListener('DOMAttrModified', hideCaption.changeTitle, false);
},

onTabClose:function(event){
event.target.removeEventListener('DOMAttrModified', hideCaption.changeTitle, false);
},

maxisize:function(){
window.resizeTo(0,0);
//window.maximize();
mWindow.setAttribute('hidechrome','true');
document.getElementById('hc-space').setAttribute('hidden','true');
if (DISPLAY_TITLE == true)
document.getElementById('hc-title').setAttribute('hidden','false');
document.getElementById('hc-appLogo').setAttribute('hidden','false');
document.getElementById('minimize-button').setAttribute('hidden','false');
document.getElementById('close-button').setAttribute('hidden','false');
window.moveTo(screen.availLeft,screen.availTop);
window.resizeTo(screen.availWidth,screen.availHeight);
hcPrefs.setBoolPref('wFullscreen',true);
},

restore:function(){
window.resizeTo(0,0);
mWindow.setAttribute('hidechrome','false');
document.getElementById('hc-space').setAttribute('hidden','false');
document.getElementById('hc-title').setAttribute('hidden','true');
document.getElementById('hc-appLogo').setAttribute('hidden','true');
document.getElementById('minimize-button').setAttribute('hidden','true');
document.getElementById('close-button').setAttribute('hidden','true');
hideCaption.restoreWinPos();
hcPrefs.setBoolPref('wFullscreen',false);
},

keepWinPos:function(){
if ((STATE_MAXIMIZED != window.windowState) && !(mWindow.getAttribute('hidechrome') == 'true')) {
hideCaption.saveWinPos();
hcPrefs.setIntPref('wLeft',wLeft);
hcPrefs.setIntPref('wTop',wTop);
hcPrefs.setIntPref('wWidth',wWidth);
hcPrefs.setIntPref('wHeight',wHeight);
};
},

saveWinPos:function(){
wLeft =screenX;
wTop=screenY;
wWidth = window.outerWidth;
wHeight=window.outerHeight;
},

restoreWinPos:function(){
window.moveTo(wLeft,wTop);
window.resizeTo(wWidth,wHeight);
},
};

hideCaption.init();


在隔壁找到的一个,
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
6楼#
发布于:2010-03-03 16:55
方法一样,就是代码不一样,需要的朋友可以看看
bokonger
小狐狸
小狐狸
  • UID32104
  • 注册日期2010-02-23
  • 最后登录2011-04-09
  • 发帖数27
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
7楼#
发布于:2010-03-03 16:55
const SHOW_GECKO_VERSION = true //show gecko version on title when start
const TITLE_ALIGN = 'right' //set title Align
const MAXTHON_LIKE = false //toggle maxthon like style
const MAXTHON_LIKETITLE_ALIGN = 'left' //set maxthon like style title Align
const USE_TAB_TITLE = false //using tabs title as titlebar title ^^
const DEFALUT_TITLE = '' //the defaule app name for title display
const DISPLAY_TITLE = true //if titlebar display
const LOGO_PADDING = 2 //Smaller logo size
const NO_TITLE = false //display webpage title on titlebar or not

var curTitle = DEFALUT_TITLE

var hideCaption={

init:function(){
var mWindow = document.getElementById('main-window');

if(mWindow)
{

var tMenu = document.getElementById('toolbar-menubar');

//fix something for version 3.0
try
{
tMenu.childNodes[1].setAttribute('hidden','true');
tMenu.childNodes[2].setAttribute('hidden','true');
}
catch(e) {};

//show Firefox Logo
var logo = document.createElement('hbox');
logo.setAttribute('id','hc-logo');
var logoimg =document.createElement('image');
logoimg.setAttribute('id','hc-logoimg');
logoimg.setAttribute('src','chrome://branding/content/icon48.png');
logoimg.setAttribute('style', 'max-height:20px ;max-width:20px;padding:' + LOGO_PADDING + 'px !important;');
logoimg.setAttribute('ondblclick','BrowserTryToCloseWindow();');
logo.appendChild(logoimg);
tMenu.insertBefore(logo,document.getElementById('menubar-items'));

//show title
var tBox = document.createElement('hbox');
tBox.setAttribute('id','hc-title');
tBox.setAttribute('align','center');
tBox.setAttribute('flex','1');

var tLabel =document.createElement('label');
tLabel.setAttribute('id','contents-title');
tLabel.setAttribute('crop','right');
tLabel.setAttribute('flex','1');
if (DISPLAY_TITLE == false) tLabel.setAttribute('hidden','true');

if (DEFALUT_TITLE == '')
curTitle = mWindow.getAttribute('title');
var vTitle =curTitle;

//show ver in title
if (SHOW_GECKO_VERSION)
{
vTitle = vTitle + ' ' + navigator.product +'/' + navigator.productSub
};
tLabel.setAttribute('value',vTitle);
tBox.appendChild(tLabel);

//toggle maxthon style
if (!MAXTHON_LIKE){
//My faves
tLabel.setAttribute('style', 'text-align:'+TITLE_ALIGN+';font-weight: bold;');
tMenu.appendChild(tBox);
}
else
{
//Maxthon Like
tLabel.setAttribute('style', 'text-align:'+MAXTHON_LIKETITLE_ALIGN+';font-weight: bold;');
tMenu.insertBefore(tBox,document.getElementById('menubar-items'));
}

//show control buttons
var bMin =document.getElementById('minimize-button');
tMenu.appendChild(bMin);

var bClose =document.getElementById('close-button');
tMenu.appendChild(bClose);

//set browser
window.resizeTo(0,0); //or you can try window.maximize();
mWindow.setAttribute('hidechrome','true');
document.getAnonymousElementByAttribute(document.getElementById('status-bar'),'class','statusbar-resizerpanel').setAttribute('hidden','true')
window.moveTo(screen.availLeft,screen.availTop);
window.resizeTo(screen.availWidth,screen.availHeight);

// Listeners
if (!NO_TITLE) {
gBrowser.selectedTab.addEventListener('DOMAttrModified', hideCaption.onTabOpen, false);
gBrowser.tabContainer.addEventListener('TabOpen', hideCaption.onTabOpen, false);
gBrowser.tabContainer.addEventListener('TabClose', hideCaption.onTabClose, false);
}
}
},

changeTitle:function(event)
{
if (event.target !=gBrowser.selectedTab) return;
var newTitle='';
if (event.attrName == 'label') {
newTitle = event.newValue;
if (USE_TAB_TITLE == false)
newTitle = newTitle + ' - ' + curTitle;
document.getElementById('contents-title').setAttribute('value',newTitle);
return;
}
else if ((event.attrName == 'selected') &&(event.newValue == 'true'))
{
var tab = gBrowser.mTabContainer.childNodes[gBrowser.mTabContainer.selectedIndex];
newTitle=tab.getAttribute('label');
if (USE_TAB_TITLE == false)
newTitle = newTitle + ' - ' +curTitle;
document.getElementById('contents-title').setAttribute('value',newTitle);
return;
}
},

onTabOpen:function(event){
event.target.addEventListener('DOMAttrModified', hideCaption.changeTitle, false);
},

onTabClose:function(event){
event.target.removeEventListener('DOMAttrModified', hideCaption.changeTitle, false);
},

};

hideCaption.init();

复制上面的代码,改成js文件,目前我使用觉得最稳定的一个
游客

返回顶部