// ==UserScript== // @name stylishEditButton.uc.js // @namespace http://d.hatena.ne.jp/Cherenkov/ // @description http://d.hatena.ne.jp/Cherenkov/20090703/p1 // @include chrome://browser/content/browser.xul // ==/UserScript== (function(){ function contextEdit(event) { var item = document.evaluate('//*[@class="style-menu-item"]', stylishPopup, null, 7, null); var btn = document.evaluate('//*[@class="stylishEditBtn"]', stylishPopup, null, 7, null); if(item.snapshotLength == btn.snapshotLength) return false; if(event.type == "popupshowing") { var style = Components.classes["@userstyles.org/style;1"] .getService(Components.interfaces.stylishStyle) .findForUrl(stylishCommon.cleanURI(content.document.location.href), false, 0, {}); for(var i = 0; i < item.snapshotLength; i++) { var editBtn = document.createElement("menuitem"); editBtn.setAttribute("class", "stylishEditBtn"); editBtn.setAttribute("id", style[i].id); editBtn.setAttribute("label", "edit " + style[i].name); editBtn.addEventListener("command", function() { stylishCommon.openEditForId(this.id); }, false); item.snapshotItem(i).parentNode.insertBefore(editBtn, item.snapshotItem(i).nextSibling); } } else { for(var i = 0; i