MozillaZine


[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
Diorser

User avatar
 
Posts: 1009
Joined: June 22nd, 2005, 6:57 am

Post Posted August 13th, 2006, 6:12 am

Zoolcar9 wrote:
Diorser wrote:Is it possible to change default source viewer without adding any extension by using UserChrome.js or anything else but an extension ?
If you're using 2.0 alpha or beta:
http://kb.mozillazine.org/View_source.editor.external
http://kb.mozillazine.org/View_source.editor.path

Coming back on that one and to clarify, and because currently using Fx1.5.0.6, is there a real technical explanation why it would not be possible to make a user js to open source with an external editor ? (something close to LaunchIE ?)

Just replacing the existing menu "View page source" command by an other editor would fit the need, without creating new button or new menus.

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted August 13th, 2006, 10:15 am

Zoolcar9 wrote:


  • <a href="data:application/x-javascript;base64,KGZ1bmN0aW9uKCkgewogIGZ1bmN0aW9uIGVsbUluc3BlY3RvcihhTm9kZSkgewogICAgdmFyIG1pID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgibWVudWl0ZW0iKTsKICAgIG1pLnNldEF0dHJpYnV0ZSgibGFiZWwiLCBhTm9kZS5pZCA9PSAiY29udGVudEFyZWFDb250ZXh0TWVudSIKICAgICAgPyAiSW5zcGVjdCBFbGVtZW50IgogICAgICA6ICJJbnNwZWN0IENocm9tZSBFbGVtZW50Iik7CiAgICBtaS5zZXRBdHRyaWJ1dGUoIm9uY29tbWFuZCIsICJpbnNwZWN0RE9NRG9jdW1lbnQoZG9jdW1lbnQucG9wdXBOb2RlKSIpOwogICAgaWYoYU5vZGUuaWQgIT0gImNocm9tZS1pbnNwZWN0b3IiKQogICAgICBhTm9kZS5hcHBlbmRDaGlsZChkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJtZW51c2VwYXJhdG9yIikpOwogICAgYU5vZGUuYXBwZW5kQ2hpbGQobWkpOwogIH0KCiAgdmFyIHBvcHVwcyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lK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uc2V0QXR0cmlidXRlKCJvbmNvbW1hbmQiLAogICAgInZhciB0YWJicm93c2VyID0gZ2V0QnJvd3NlcigpOyAiICsKICAgICJpbnNwZWN0RE9NRG9jdW1lbnQodGFiYnJvd3Nlci5tQ29udGV4dFRhYi5sb2NhbE5hbWUgPT0gJ3RhYnMnIiArCiAgICAiID8gZ0Jyb3dzZXIuY29udGVudERvY3VtZW50IiArCiAgICAiIDogdGFiYnJvd3Nlci5tQ29udGV4dFRhYi5saW5rZWRCcm93c2VyLmNvbnRlbnREb2N1bWVudCk7Iik7Cn0pKCk7Cgo%3D">Element Inspector</a>
    Right click anywhere on content or browser window to inspect the element with DOMI


This is very nice! Thanks
A few weeks ago I added a toolbarbutton to open up DomI and did away with Inspector widget extension to cut down on number of extensions installed. Now, with your script I have something that in my opinion is much better for me. I didn't catch it at first but notice now it works for some Chrome elements too. This is great!

aranittara

User avatar
 
Posts: 32
Joined: July 31st, 2006, 6:25 am

Post Posted August 13th, 2006, 12:09 pm

// View Source in Tab on middle click
// Original code is View Source in Tab extension by LouCypher (aka Zoolcar9)
// http://loucypher.wordpress.com/projects ... ce-in-tab/

(function() {
var menuID = ["view-menu", "frame"];
var menuCmd = ["View:PageSource", "gContextMenu.viewFrameSource();"];
var itemAttr = ["command", "oncommand"];
var doc = ["content.document", "gContextMenu.target.ownerDocument"];

for(var i = 0; i < doc.length; i++) {
var menuPopup = document.getElementById(menuID[i]).getElementsByTagName('menupopup')[0];
var menuItems = menuPopup.getElementsByTagName("menuitem");
for(var j = 0; j < menuItems.length; j++) {
var menuItem = menuItems[j];
if(menuItem.hasAttribute(itemAttr[i]) && menuItem.getAttribute(itemAttr[i]) == menuCmd[i])
menuItem.setAttribute("onclick", "viewSourceInTab(" + doc[i] + ", event);");
}
}

var contextViewSource = document.getElementById("context-viewsource");
contextViewSource.setAttribute("onclick", "viewSourceInTab(content.document, event)");

})();

function viewSourceInTab(aDocument, aEvent) {
try {
gBrowser.mPrefs.getBoolPref("viewSourceInTab.loadInNewTab");
} catch(ex) {
gBrowser.mPrefs.setBoolPref("viewSourceInTab.loadInNewTab", true);
}

try {
gBrowser.mPrefs.getBoolPref("viewSourceInTab.loadInBackground");
} catch(ex) {
gBrowser.mPrefs.setBoolPref("viewSourceInTab.loadInBackground", false);
}

var sourceURL = "view-source:" + aDocument.location.href;
if(aEvent.button == 1) { //middle click
if(gBrowser.mPrefs.getBoolPref("viewSourceInTab.loadInNewTab")) {
var newTab = gBrowser.addTab(sourceURL);
if(!gBrowser.mPrefs.getBoolPref("viewSourceInTab.loadInBackground"))
gBrowser.selectedTab = newTab; //view source in new tab
} else
loadURI(sourceURL); //view source in current tab
} else if(aEvent.button == 2) { //right click
aEvent.stopPropagation();
openWebPanel(aDocument.title, sourceURL); //view source in sidebar
}
closeMenus(aEvent.target);
}
can someone modify this so that it opens in a tab on left click instead?
-Aranittara

pile0nades
 
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post Posted August 14th, 2006, 12:07 am

Another Inspect Element bug. When I right click in the page, I get both Inspect Element, and Inspect Chrome Element menuitems. I'm using Menu Editor if that's important, but I can't find the items in Menu Editor's window.

Image

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1b1) Gecko/20060811 BonEcho/2.0b1 - Build ID: 2006081104
Linkify bug numbers - test: bug 258287

Schrade

User avatar
 
Posts: 1187
Joined: March 17th, 2004, 12:24 am

Post Posted August 14th, 2006, 1:07 am

Zoolcar9 wrote:
  • Element Inspector
    Right click anywhere on content or browser window to inspect the element with DOMI


My god this is damn useful. Thank you so much, Zoolcar9!
"Linux is for those who hate Windows, BSD is for those who love Unix." -Some Guy
Try my themes: QuBranch and QuTrunk
Fix Firefox's Resized image scrolling speed: <b>Bug 163975</b>

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 14th, 2006, 7:59 am

pile0nades wrote:Another Inspect Element bug. When I right click in the page, I get both Inspect Element, and Inspect Chrome Element menuitems. I'm using Menu Editor if that's important, but I can't find the items in Menu Editor's window.

Yes, that must be Menu Editor. Try <a href="data:application/x-javascript;base64,KGZ1bmN0aW9uKCkgewogIGZ1bmN0aW9uIGVsbUluc3BlY3RvcihhTm9kZSwgYUluZGV4KSB7CiAgICB2YXIgbWkgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJtZW51aXRlbSIpOwogICAgbWkuaWQgPSBhSW5kZXggPyAiY29udGV4dC1pbnNwZWN0b3ItIiArIGFJbmRleCA6ICJjb250ZXh0LWluc3BlY3RvciI7CiAgICBtaS5zZXRBdHRyaWJ1dGUoImxhYmVsIiwgYU5vZGUuaWQgPT0gImNvbnRlbnRBcmVhQ29udGV4dE1lbnUiCiAgICAgID8gIkluc3BlY3QgRWxlbWVudCIKICAgICAgOiAiSW5zcGVjdCBDaHJvbWUgRWxlbWVudCIpOwogICAgbWkuc2V0QXR0cmlidXRlKCJvbmNvbW1hbmQiLCAiaW5zcGVjdERPTURvY3VtZW50KGRvY3VtZW50LnBvcHVwTm9kZSkiKTsKICAgIGlmKGFOb2RlLmlkICE9ICJjaHJvbWUtaW5zcGVjdG9yLXBvcHVwIikgewogICAgICB2YXIgbXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJtZW51c2VwYXJhdG9yIik7CiAgICAgIG1zLmlkID0gbWkuaWQgKyAiLXNlcGFyYXRvciI7CiAgICAgIGFOb2RlLmFwcGVuZENoaWxkKG1zKTsKICAgIH0KICAgIGFOb2RlLmFwcGVuZENoaWxkKG1pKTsKICB9CgogIHZhciBwb3B1cHMgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgicG9wdXAiKTsKICBmb3IodmFyIGkgPSAwOyBpIDwgcG9wdXBzLmxlbmd0aDsgaSsrKSB7CiAgICB2YXIgcG9wdXAgPSBwb3B1cHNbaV07CiAgICBpZihwb3B1cC5nZXRFbGVtZW50c0J5VGFnTmFtZSgibWVudWl0ZW0iKS5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KTsgIiArIC8vdGhhbmtzLCB6ZW5pa28KICAgICJpbnNwZWN0RE9NRG9jdW1lbnQodGFiYnJvd3Nlci5tQ29udGV4dFRhYi5sb2NhbE5hbWUgPT0gJ3RhYnMnIiArCiAgICAiID8gZ0Jyb3dzZXIuY29udGVudERvY3VtZW50IiArCiAgICAiIDogdGFiYnJvd3Nlci5tQ29udGV4dFRhYi5saW5rZWRCcm93c2VyLmNvbnRlbnREb2N1bWVudCk7Iik7Cn0pKCk7Cgo%3D">this</a>

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Schrade

User avatar
 
Posts: 1187
Joined: March 17th, 2004, 12:24 am

Post Posted August 14th, 2006, 1:36 pm

Zoolcar9, does that replace your original Element Inspector? Or is it only fixing a bug if you use Menu Editor?
"Linux is for those who hate Windows, BSD is for those who love Unix." -Some Guy
Try my themes: QuBranch and QuTrunk
Fix Firefox's Resized image scrolling speed: <b>Bug 163975</b>

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 14th, 2006, 2:07 pm


It just adds IDs to "Inspect..." menuitems and menuseparators to 'fix' the bug with Menu Editor (and MenuManipulator).

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

XerBlade

User avatar
 
Posts: 865
Joined: October 4th, 2005, 10:45 pm
Location: Nashville, TN, US

Post Posted August 14th, 2006, 3:32 pm

Interesting, I'm not reproducing those problems with MenuManipulator, just on my profiles with Menu Editor.
User Agent
Extensions
AMD64/2.41GHz RAM/1.0GB ATI/256MB-GDDR3/128-bit/8xAGP Cable6.0M/384kbps

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted August 14th, 2006, 4:01 pm

XerBlade wrote:Interesting, I'm not reproducing those problems with MenuManipulator, just on my profiles with Menu Editor.

I use "Menu Editor" and haven't seen the problem mentioned and I have really used the inspector quite a bit. I do see one thing which I think is unrelated, first right click within a page will double up the separators, as in one directly below the other. If I right click again it's back to normal.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted August 14th, 2006, 4:34 pm


It depends on your menu arrangements. I can't explain this (with my broken English), but you'll know why if you know how Menu Editor and MenuManipulator works.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

pile0nades
 
Posts: 756
Joined: May 15th, 2005, 2:31 am

Post Posted August 14th, 2006, 10:02 pm

One more thing. I have Scrapbook and Stylish installed, and when I right click on either of their status bar icons, I get this.
Image
It doesn't happen when I right click the Greasemonkey or Gmail Manager icon though.

Edit: for reference, I figured it out. Both Stylish and Scrapbook auto-generate their menus with javascript when you click the icon, so the menus have no actual items in them on startup, which is when the inspect menuitems get added. The scripts checks for any menuitems in the menu before adding them.
Last edited by pile0nades on October 29th, 2006, 7:33 am, edited 1 time in total.
Linkify bug numbers - test: bug 258287

Chad-)
 
Posts: 166
Joined: August 29th, 2005, 7:01 am

Post Posted August 15th, 2006, 1:17 am

Can anyone please look into this?
Atleast into the mouse gestures script since it's there already. Maybe it needs only a couple of minor modifications. :| :-s

neomi

User avatar
 
Posts: 2
Joined: August 8th, 2006, 5:43 pm
Location: cyber space

Post Posted August 15th, 2006, 3:48 am

Code: Select all
(function () {
   var navbar = document.getElementById('nav-bar');
   var tabbrowser = document.getElementById('content');
   var tabpanels = tabbrowser.mPanelContainer;
   tabpanels.parentNode.insertBefore(navbar, tabpanels);
})();


I move navbar to the bottom of the tabbar, but now I can't custom the navbar, what happen?

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted August 15th, 2006, 5:12 pm

neomi wrote:I move navbar to the bottom of the tabbar, but now I can't custom the navbar, what happen?
Because it isn't in the toolbox any more.

Phil

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests