Talk:Knowing Your Own Metadata

From GreaseSpot Wiki
Jump to navigationJump to search

The "parseHeaders" function contains an error with the "filter" method on line 5. It returns this error when attempting to use it:

   TypeError: /\/\/ @/ is not a function

on this line:

   var lines = metadataBlock.split(/\n/).filter(/\/\/ @/);

According to the MDN docs, the argument should be a callback, not a RegExp. As shown on this userscripts.org post, changing it to the following will fix it.

   var lines = metadataBlock.split(/\n/).filter(function (element, index, array) {
       return /\/\/ @/.test(element);
   });