Stylish 0.2.1 (Now with repository!)

Talk about add-ons and extension development.
Locked
User avatar
logan
Posts: 3453
Joined: May 22nd, 2003, 3:51 pm
Location: NGC 2403
Contact:

Post by logan »

np wrote:
Motohiko wrote:The locationbar uses <xul:textbox> widget, and <xul:textbox> widget is binded to <html:input> widget.

Indeed. Remember that the namespace gives you XUL vs HTML, not chrome vs. content. They'll be the same thing in 95% of cases, but here's one exception.

bummer :I

np wrote:A workaround would be to add

Code: Select all

@-moz-document url-prefix("http://") {}

to each style you want to always show up. This won't do anything other than make Stylish think the style applies to all (http) pages.

I noticed that last night. url-prefix(http) is probably better as it'll catch https:// too.

np wrote:(Actually this kind of trick might work for the first problem too.)

Well, if you could wrap everything inside of @-moz-document(http), but I already make heavy use of @-moz-document() and you can't have one inside of another. Guess I could just wrap the general stuff...

np wrote:
logan wrote:Is there any additional overhead beyond what the user{Chrome,Content}.css equivalents use?

There's a bit of time spent at app startup to register all the styles, but between loading pages there should be no difference between user*.css and Stylish.

Good to know, thanks.
********
Posts: 947
Joined: August 24th, 2005, 12:23 pm

Post by ******** »

np wrote:
desertfox wrote:i was trying to customize the Stylish statusbar icon (no offense to your original, it's great), but when i used the following code, clicking on the icon no longer brought up the menu!

Looks like a Gecko bug. Switching from opacity: 0 to visibility:hidden seems to make it work.

[edit]Bug 322440 filed[/edit]


interesting, well i'll try that then :D

and i also voted for your bug

stylish is quickly jumping up all my list of essential extensions :)

edit: "Switching from opacity: 0 to visibility:hidden" is working, thanks :)
User avatar
logan
Posts: 3453
Joined: May 22nd, 2003, 3:51 pm
Location: NGC 2403
Contact:

Post by logan »

The following causes the style to show up 3 times on the stylish statusbar menu:

Code: Select all

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain(cnn.com) { }
@-moz-document url-prefix(http://www) { }
@-moz-document url-prefix(http) { }

I'm getting this when trying to add a new style after deleting all of the builtin styles on the first run after installing stylish (get all that? :)):
Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]" nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" location: "JS frame :: chrome://browser/content/utilityOverlay.js :: getShellService :: line 329" data: no

Had to remove all rules, then exit before it'd take anything new. It's ok if you add a new one with one or more of the builtin remaining.
Motohiko
Posts: 65
Joined: November 22nd, 2003, 8:05 pm
Location: Japan
Contact:

Post by Motohiko »

logan wrote:I'm getting this when trying to add a new style after deleting all of the builtin styles on the first run after installing stylish (get all that? :)):
Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]" nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" location: "JS frame :: chrome://browser/content/utilityOverlay.js :: getShellService :: line 329" data: no

Had to remove all rules, then exit before it'd take anything new. It's ok if you add a new one with one or more of the builtin remaining.
I got another error.
Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIRDFContainer.AppendElement]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://stylish/content/rdfds.js :: anonymous :: line 582" data: no
And there is a comment in the code:
//for some reason, this will throw if you delete everything then add in the same session.

EDIT:
OK. The patch for this:

Code: Select all

--- chrome/content/stylish.js.bak   2005-12-29 12:56:22.000000000 +0900
+++ chrome/content/stylish.js   2006-01-06 20:06:16.000000000 +0900
@@ -163,6 +163,9 @@
       } else {
          //add the node
          var container = stylishCommon.ds.getNode(stylishCommon.containerURI);
+         if (!container.isSeq()) {
+            container.makeSeq();
+         }
          var node = stylishCommon.ds.getAnonymousNode();
          node.addTarget(stylishCommon.descriptionURI, description);
          node.addTarget(stylishCommon.enabledURI, enabled ? "true" : "false");
[b]EDIT (7 Jan): The patch above doesn't work.
Last edited by Motohiko on January 7th, 2006, 4:54 am, edited 1 time in total.
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

Thanks for the testing and the patch. I'm gone for a week starting tomorrow, but I'll take a look at both issues when I get back.
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

The author of Search Engine Ordering tells me that he's loaded a new version of 0.5.2 onto his website which removes the conflict, so anyone who wants to run both should uninstall SEO and reinstall it from there. Future versions of SEO will not conflict with Stylish.
********
Posts: 947
Joined: August 24th, 2005, 12:23 pm

Post by ******** »

np wrote:The author of Search Engine Ordering tells me that he's loaded a new version of 0.5.2 onto his website which removes the conflict, so anyone who wants to run both should uninstall SEO and reinstall it from there. Future versions of SEO will not conflict with Stylish.


sweet. thanks for clearing up the problem. :)
User avatar
logan
Posts: 3453
Joined: May 22nd, 2003, 3:51 pm
Location: NGC 2403
Contact:

Post by logan »

Motohiko wrote:I got another error.
Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIRDFContainer.AppendElement]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://stylish/content/rdfds.js :: anonymous :: line 582" data: no

Huh, that's what I get also. Must have copied the wrong error..

Motohiko wrote:OK. The patch for this: ...

This doesn't make a difference for me. I added an alert inside of if(!container.isSeq()), but it's never hit.
User avatar
Thumper
Posts: 8037
Joined: November 4th, 2002, 5:42 pm
Location: Linlithgow, Scotland
Contact:

Post by Thumper »

I'm getting a

Code: Select all

TypeError:
containedDocShells.getNext().QueryInterface(Components.interfaces.nsIDocShell).contentViewer has no properties


alert when I'm trying to add or edit a rule which is being used on the current tab if Adblock is enabled. I can't enable or disable rules using the Stylish context menu either, it silently fails.

Disabling Adblock (using the context menu on the adblock icon) allows me to do both normally.

- Chris
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

Does that happen on any page or just pages that have blocked frames/iframes?
User avatar
Thumper
Posts: 8037
Joined: November 4th, 2002, 5:42 pm
Location: Linlithgow, Scotland
Contact:

Post by Thumper »

Just the latter by quick experimentation.

- Chris
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

Should be fixable by changing the following code in stylishCommon.js

Code: Select all

         while (containedDocShells.hasMoreElements()) {
            // Get the corresponding document for this docshell
            docs[docs.length] = containedDocShells.getNext().QueryInterface(Components.interfaces.nsIDocShell).contentViewer.DOMDocument;
         }

to

Code: Select all

         while (containedDocShells.hasMoreElements()) {
            // Get the corresponding document for this docshell
            var viewer = containedDocShells.getNext().QueryInterface(Components.interfaces.nsIDocShell).contentViewer;
            // Adblock might block iframes/frames. Null check the content viewer.
            if (viewer) {
               docs[docs.length] = viewer.DOMDocument;
            }
         }
User avatar
logan
Posts: 3453
Joined: May 22nd, 2003, 3:51 pm
Location: NGC 2403
Contact:

Post by logan »

I removed the duplicate menu entries by throwing this at the end of overlay.js:getApplicableStyles():

Code: Select all

var styles = [];
for(var i = 0; i < applicableStyles.length; i++)
  if(styles.indexOf(applicableStyles[i], 0) < 0)
    styles.push(applicableStyles[i]);
  return styles;
mastavic
Posts: 1090
Joined: March 28th, 2004, 12:18 am
Location: San Francisco/San Jose, California

Post by mastavic »

lol you lost me at "Stylish is to CSS what Greasemonkey is to JavaScript," but thanks for creating an extension that seems to please a lot of people.

-=Victor Ly/MaStA ViC
Motohiko
Posts: 65
Joined: November 22nd, 2003, 8:05 pm
Location: Japan
Contact:

Post by Motohiko »

logan wrote:
Motohiko wrote:I got another error.
Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIRDFContainer.AppendElement]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://stylish/content/rdfds.js :: anonymous :: line 582" data: no

Huh, that's what I get also. Must have copied the wrong error..

Motohiko wrote:OK. The patch for this: ...

This doesn't make a difference for me. I added an alert inside of if(!container.isSeq()), but it's never hit.
Ah, my bad. Mozilla's RDF parser has a bug about this (SHIMODA Hirosi, TbE's author, pointed this out in Jan 2003[written in Japanese]).


So avoid this, we should add dummy entry not to make datasource empty. Like this:

Code: Select all

     this.deleteStyle = function() {
        var styles = this.getSelectedStyles();
        for (var i = 0; i < styles.length; i++) {
           var node = stylishCommon.ds.getNode(styles[i]);
           //unapply the style if it's applied
           if (node.getTarget(stylishCommon.enabledURI).getValue() == "true") {
              stylishCommon.unregisterNode(node);
           }
           //delete it from the file
           stylishCommon.ds.deleteRecursive(node);
        }
 
+       // XXX to avoid the error below, add dummy entry and make always at lease one entry in the tree.
+       var container = stylishCommon.ds.getNode(stylishCommon.containerURI);
+       if (container.getChildCount() == styles.length){
+          var node = stylishCommon.ds.getAnonymousNode();
+          // XXX !!!MAKE LOCALIZABLE!!!
+          node.addTarget(stylishCommon.descriptionURI, "New Style");
+          node.addTarget(stylishCommon.enabledURI, "false");
+          node.addTarget(stylishCommon.codeURI, "");
+          container.addChild(node);
+       }
        stylishCommon.ds.save();
        stylishCommon.ds.refresh(true);
 
        //XXX there's a bug somewhere that deleting a style will make all the styles below it not display. to work around this, refresh the tree
        //remember scroll position. don't remember selection, because everything selected will have been deleted!
        var topVisibleRow = this.getTopVisibleRow();
Locked