Announce and Discuss the Latest Theme and Extension Releases.
pile0nades
Posts: 756Joined: May 15th, 2005, 2:31 am
Posted October 27th, 2006, 10:48 pm
I am making the Copy Feed URL script I requsted above, that adds a menuitem to the feed icon on right-click. The copying works, but I need to only show it when the feed icon is right-clicked. The code is based on code from Zoolcar9's Element Inspector.
- Code: Select all
function cfu_addMenuItem(aNode, aIndex) { var mi = aNode.appendChild(document.createElement("menuitem")); mi.id = "context-copyfeedurl"; mi.setAttribute("label", "Copy Feed URL"); mi.setAttribute("oncommand", "cfu_copyFeedURL(document.getElementById('feed-button').getAttribute('feed'))"); mi.style.display = "none"; var ms = aNode.insertBefore(document.createElement("menuseparator"), mi); ms.id = mi.id + "-separator";
}
function cfu_copyFeedURL(url) { var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] .getService(Components.interfaces.nsIClipboardHelper); gClipboardHelper.copyString(url); }
var cfu_menu = document.getElementById("toolbar-context-menu") cfu_addMenuItem(cfu_menu);
cfu_menu.addEventListener("onpopupshown", "if(document.popupNode.id == 'feed-button') document.getElementById('context-copyfeedurl').style.display = '-moz-box'", false); cfu_menu.addeventListener("onpopuphidden", "document.getElementById('context-copyfeedurl').style.display = 'none'", false);
How do I make this work?
Zoolcar9

Posts: 2225Joined: November 9th, 2004, 6:45 pmLocation: Jakarta, Indonesia (UTC+7)
Posted October 28th, 2006, 12:36 am
- Code: Select all
cfu_menu.addEventListener("popupshown", function() { if(document.popupNode.id == 'feed-button') document.getElementById('context-copyfeedurl').style.display = '-moz-box'; }, false); cfu_menu.addEventListener("popuphidden", function() { document.getElementById('context-copyfeedurl').style.display = 'none'; }, false);
pile0nades
Posts: 756Joined: May 15th, 2005, 2:31 am
Posted October 28th, 2006, 5:49 am
Doh! Thanks for that. There was another bug where the item was hidden if a submenu was opened and hidden, but I fixed that by checking that the event target was the menu. Here's the finished script:
Copy Feed URL
Adds a menuitem to the feed icon's right-click menu, letting you copy the feed URL to the clipboard without having to first view/add the feed.
<a href="data:text/jav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ImZlZWQtYnV0dG9uIjsNCiAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiY29udGV4dC1jb3B5ZmVlZHVybCIpLmhpZGRlbiA9ICFpc0ZlZWRCdXR0b247DQogICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImNvbnRleHQtY29weWZlZWR1cmwtc2VwYXJhdG9yIikuaGlkZGVuID0gIWlzRmVlZEJ1dHRvbjsNCiAgfSwgZmFsc2UpOw0KfSkoKTsNCg0KZnVuY3Rpb24gY2Z1X2NvcHlGZWVkVVJMKHVybCkgew0KICB2YXIgZ0NsaXBib2FyZEhlbHBlciA9IENvbXBvbmVudHMuY2xhc3Nlc1siQG1vemlsbGEub3JnL3dpZGdldC9jbGlwYm9hcmRoZWxwZXI7MSJdDQogICAgLmdldFNlcnZpY2UoQ29tcG9uZW50cy5pbnRlcmZhY2VzLm5zSUNsaXBib2FyZEhlbHBlcik7IA0KICBnQ2xpcGJvYXJkSGVscGVyLmNvcHlTdHJpbmcodXJsKTsNCn0NCg%3D%3D">copyfeedurl.uc.js</a><br><br>
Last edited by pile0nades on October 28th, 2006, 8:49 pm, edited 3 times in total.
Zoolcar9

Posts: 2225Joined: November 9th, 2004, 6:45 pmLocation: Jakarta, Indonesia (UTC+7)
Posted October 28th, 2006, 6:44 am
You can also use <code>hidden</code> property:
- Code: Select all
cfu_menu.addEventListener("popupshown", function() { var isFeedButton = document.popupNode.id == "feed-button"; document.getElementById("context-copyfeedurl").hidden = !isFeedButton; document.getElementById("context-copyfeedurl-separator").hidden = !isFeedButton; }, false);
* remove <code>mi.style.display = "none";</code> from <code>cfu_addMenuItem</code> function.
<a class="postlink" href="data:application/x-javascript;base64,Ly8gQ29weSBGZWVkIFVSTCBtZW51aXRlbQovLyBieSBwaWxlMG5hZGVzCi8vIFJpZ2h0LWNsaWNrIHRoZSBmZWVkIGljb24gYW5kIGNsaWNrIENvcHkgRmVlZCBVUkwKCgooZnVuY3Rpb24oKSB7CiAgdmFyIG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udC5nZXRFbGVtZW50QnlJZCgiY29udGV4dC1jb3B5ZmVlZHVybC1zZXBhcmF0b3IiKS5oaWRkZW4gPSAhaXNGZWVkQnV0dG9uOwogIH0sIGZhbHNlKTsKfSkoKTsKCmZ1bmN0aW9uIGNmdV9jb3B5RmVlZFVSTCh1cmwpIHsKICB2YXIgZ0NsaXBib2FyZEhlbHBlciA9IENvbXBvbmVudHMuY2xhc3Nlc1siQG1vemlsbGEub3JnL3dpZGdldC9jbGlwYm9hcmRoZWxwZXI7MSJdCiAgICAuZ2V0U2VydmljZShDb21wb25lbnRzLmludGVyZmFjZXMubnNJQ2xpcGJvYXJkSGVscGVyKTsgCiAgZ0NsaXBib2FyZEhlbHBlci5jb3B5U3RyaW5nKHVybCk7Cn0KCg%3D%3D">copyfeedurl.uc.js</a>
JFYI: without the <code>(function() {</code> ... <code>})()</code>, all functions and variables in the script will become global.
pile0nades
Posts: 756Joined: May 15th, 2005, 2:31 am
Posted October 28th, 2006, 7:51 pm
Zoolcar9 wrote:You can also use <code>hidden</code> property: - Code: Select all
cfu_menu.addEventListener("popupshown", function() { var isFeedButton = document.popupNode.id == "feed-button"; document.getElementById("context-copyfeedurl").hidden = !isFeedButton; document.getElementById("context-copyfeedurl-separator").hidden = !isFeedButton; }, false);
* remove <code>mi.style.display = "none";</code> from <code>cfu_addMenuItem</code> function. <a class="postlink" href="data:application/x-javascript;base64,Ly8gQ29weSBGZWVkIFVSTCBtZW51aXRlbQovLyBieSBwaWxlMG5hZGVzCi8vIFJpZ2h0LWNsaWNrIHRoZSBmZWVkIGljb24gYW5kIGNsaWNrIENvcHkgRmVlZCBVUkwKCgooZnVuY3Rpb24oKSB7CiAgdmFyIGNmdV9tZW51ID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoInRvb2xiYXItY29udGV4dC1tZW51Iik7CiAgY2Z1X2FkZE1lbnVJdGVtKGNmdV9tZW51KTsKCiAgZnVuY3Rpb24gY2Z1X2FkZE1lbnVJdGVtKGF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TCh1cmwpIHsKICB2YXIgZ0NsaXBib2FyZEhlbHBlciA9IENvbXBvbmVudHMuY2xhc3Nlc1siQG1vemlsbGEub3JnL3dpZGdldC9jbGlwYm9hcmRoZWxwZXI7MSJdCiAgICAuZ2V0U2VydmljZShDb21wb25lbnRzLmludGVyZmFjZXMubnNJQ2xpcGJvYXJkSGVscGVyKTsgCiAgZ0NsaXBib2FyZEhlbHBlci5jb3B5U3RyaW5nKHVybCk7Cn0KCg%3D%3D">copyfeedurl.uc.js</a> JFYI: without the <code>(function() {</code> ... <code>})()</code>, all functions and variables in the script will become global.
You know everything, don't you?
You removed the popuphidden event listener, but it still only shows when right clicking the feed icon. How does that work? Shouldn't it then show when right clicking anywhere else on the toolbar? Wait I got it, the popupshown event executes the function every time the toolbar context menu shows, so it gets set to hidden if not right clicking the feed button. And I know about the global thing, that's why I added the cfu_ prefix. Script updated.
pile0nades
Posts: 756Joined: May 15th, 2005, 2:31 am
Posted October 29th, 2006, 7:55 am
Greg S wrote:Zoolcar9 wrote:Greg S wrote:I'm having problems with your minutes less than 10 losing the 0. Can you fix?? If not that's OK. I've trimmed the excess out of what posted above and it works fine but I'd rather use the code you posted if you can fix the minutes.
Replace - Code: Select all
var minute = D.getMinutes();
with - Code: Select all
var minute = (D.getMinutes() < 10) ? "0" : "" + D.getMinutes();
Just for the record, I'm still using a variation of my original. After making the changes you have suggested, I lose the right side number of the minutes although the left side number now works which was my problem. Anything else to try? Mine is working fine but your code seems minimal in comparison to mine which means I like yours better. Thanks
Instead of - Code: Select all
var minute = (D.getMinutes() < 10) ? "0" : "" + D.getMinutes();
use - Code: Select all
var minute = (D.getMinutes() < 10) ? "0" + D.getMinutes() : "" + D.getMinutes();
Lost User 246017
Posts: 0Joined: December 31st, 1969, 5:00 pm
Posted October 29th, 2006, 8:19 pm
Hi, excellent extension.
I'm hoping to get a script to increase the count in MAX_HISTORY_MENU_ITEMS. The default in browser.js in Chrome is 15 but I've upped it to 25. Also, I changed the history.view.rowCount from 10 to 0 so no sites visited show in the History menu. I'm just afraid that will be overwritten when the browser gets updated every time so if it's possible to fix it in the profile userChrome I'd appreciate any assistance.
CrackTipe
Posts: 443Joined: January 4th, 2006, 12:11 am
Posted October 30th, 2006, 4:40 pm
I've been using this code to get rid of the accesskey attributes (the "_"'s that are under menus).
(function() {
var
menus = document.getElementsByTagName('menu'),
menuItems = document.getElementsByTagName('menuitem'),
menu,
menuItem;
for (var i = 0; menu = menus[i]; i++) {
menu.removeAttribute('accesskey');
}
for (var i = 0; menuItem = menuItems[i]; i++) {
menuItem.removeAttribute('accesskey');
}
})();
And it works great for the menu and context menu, but it doesn't work when I right-click in the URL bar or the Googlebar Lite search bar.
Is there anything that can be done to the code to make it work for these 2 bars?
pile0nades
Posts: 756Joined: May 15th, 2005, 2:31 am
Posted October 30th, 2006, 8:30 pm
It doesn't work for those because they are anonymous content.
Old Greg S
Posts: 0Joined: December 31st, 1969, 5:00 pm
Posted November 4th, 2006, 3:31 am
I notice in FF version 2.0 that in AddOns when right clicking an extension/theme and selecting "Visti Home Page" now opens in a new tab which I like. Is there a script for doing this in FF version 1.5.0.7? Also the "Get More Extensions" & "Get More Themes" text links as well.
And I've found another annoyance fixed in 2.0, I'd like the Customize Toolbar Window to act like the one in 2.0 which is when it's resized it stays at that size the next time it's opened
Thanks
aaron

Posts: 3130Joined: November 4th, 2002, 8:49 pmLocation: Texas
Posted November 8th, 2006, 9:30 am
I was using this code to auto-clear the search bar in Firefox 1.5, and updated today to Firefox 2.0 and it no longer works. Any ideas on what to modify to get it working again?
- Code: Select all
/* :::: Auto-clear Search Bar :::: */
var searchbarAutoclear = { init: function() { this.searchbar = document.getElementById("searchbar"); this.searchbarTextbox = this.searchbar.mTextbox; this.searchbarTextbox.addEventListener("keypress", function(event) { searchbarAutoclear.clear(event); }, false); },
clear: function(event) { if (event.keyCode == 13) { setTimeout("searchbarAutoclear.searchbar.value='';", 0); setTimeout("searchbarAutoclear.searchbarTextbox.value='';", 0); event.stopPropagation(); } } };
searchbarAutoclear.init();
Grist

Posts: 836Joined: January 27th, 2006, 9:20 pm
Posted November 8th, 2006, 9:59 am
- Code: Select all
var searchbarAutoclear = { init: function() { this.searchbar = document.getElementById("searchbar"); this.searchbar.setAttribute('oncommand', 'this.value="";'); // Clears when the button is used. this.searchbarTextbox = this.searchbar.textbox; //Changed mTextbox to textbox this.searchbarTextbox.addEventListener("keypress", function(event) { searchbarAutoclear.clear(event); }, false); },
clear: function(event) { if (event.keyCode == 13) { setTimeout("searchbarAutoclear.searchbar.value='';", 0); setTimeout("searchbarAutoclear.searchbarTextbox.value='';", 0); event.stopPropagation(); } } };
searchbarAutoclear.init();
Added this line so the button would clear the textbox:
<code>this.searchbar.setAttribute('oncommand', 'this.value="";');</code>
toozerosickz
Posts: 6Joined: April 13th, 2006, 12:49 am
Posted November 9th, 2006, 2:06 pm
How can I integrate my add-ons to the options menu like this?
<img src="http://img75.imageshack.us/img75/170/fx2optionsiy1.gif" border="0">
Lost User 246017
Posts: 0Joined: December 31st, 1969, 5:00 pm
Posted November 10th, 2006, 8:04 am
MPZ wrote:Hi, excellent extension.
I'm hoping to get a script to increase the count in MAX_HISTORY_MENU_ITEMS. The default in browser.js in Chrome is 15 but I've upped it to 25. Also, I changed the history.view.rowCount from 10 to 0 so no sites visited show in the History menu. I'm just afraid that will be overwritten when the browser gets updated every time so if it's possible to fix it in the profile userChrome I'd appreciate any assistance.
Can anyone help me out with this? Is it even possible to do using this extension?
old zeniko
Posts: 0Joined: December 31st, 1969, 5:00 pm
Posted November 10th, 2006, 8:16 am
@MPZ: Try
- Code: Select all
eval("FillHistoryMenu = " + FillHistoryMenu.toString().replace(/MAX_HISTORY_MENU_ITEMS/g, "25"));
(you'll have to install the extension first, then figure out where your profile folder is, open the chrome folder therein and add these lines to the userChrome.js file which you can edit with any text editor such as Notepad or vi)
Return to Extension/Theme Releases
Who is online
Users browsing this forum: Bing [Bot] and 0 guests
|