Changeset 8626

Show
Ignore:
Timestamp:
04/02/08 06:20:47 (5 years ago)
Author:
drry
Message:

lang/javascript/userscripts/ldrprefav.user.js:

  • 正規表現を修正しました。
  • ほか。
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/ldrprefav.user.js

    r8616 r8626  
    88// ==/UserScript== 
    99 
    10 var doneIDs = []; 
     10var filteredIDs, preFilteredIDs; 
    1111 
    1212with (this.unsafeWindow || this) { 
     
    1414                "Pheedo - Depheedo" : function(f) { 
    1515                        var item; 
    16                         for (var i = f.items.length; item = f.items[--i];) { 
     16                        for (var i = 0; item = f.items[i++];) { 
    1717                                if (item.title.indexOf("AD: ") != 0) break; 
    1818                        } 
     
    2020 
    2121                        filter(f.items, function(i) { return i.title.indexOf("AD: ") != 0 }); 
    22                         var re = /<img(?:\s+[^>]+)*?\s+src\s*=\s*["']?\s*http:\/\/www\.pheedo\.jp\/(?:img\.phdo|feeds\/tracker\.php)\?[^>]+>/g; //ig 
     22                        var re = /<img(?:\s+[^>]+)?\s+src\s*=\s*["']?\s*http:\/\/www\.pheedo\.jp\/(?:img\.phdo|feeds\/tracker\.php)\?[^>]+>(?:<\/img>)?/g; //ig 
    2323                        foreach(f.items, function(i) { i.body = i.body.replace(re, ""); }); 
    2424                }, 
    25                 "FeedBurner - Detracking and Remove Garbled" : function(f) { 
    26                         var re = /<a(?:\s+[^>]+)*?\s+href\s*=\s*["']?\s*http:\/\/[^\/]+\/~\w\/[^>]+>[\s\S]+?<\/a\s*>|<img(?:\s+[^>]+)*?\s+src\s*=\s*["']?\s*http:\/\/[^\/]+\/~\w\/[^>]+>/g; 
    27                         if (f.channel.feedlink.indexOf("http://feeds.feedburner.") != 0 && 
     25                "FeedBurner - Detracking and Filter Garbled" : function(f) { 
     26                        var re = /<a(?:\s+[^>]+)?\s+href\s*=\s*["']?\s*http:\/\/[^\/]+\/~\w\/[^>]+>[\s\S]+?<\/a\s*>|<img(?:\s+[^>]+)*?\s+src\s*=\s*["']?\s*http:\/\/[^\/]+\/~\w\/[^>]+>(?:<\/img>)?/g; 
     27                        if (! /^http:\/\/feeds\.feedburner\.(?:com|jp)\//.test(f.channel.feedlink) && 
    2828                            ! (f.items[0] && 
    29                                /^http:\/\/feeds\.feedburner\.(?:com|jp)\/~r\//.test(f.items[0].link) || 
     29                               /^http:\/\/[^\/]+\/~r\/[^\/]+/.test(f.items[0].link) || 
    3030                               re.test(f.items[0].body))) return; 
    3131 
     
    3636                        filter(f.items, function(i) { return i.author != "rssad.jp" }); 
    3737                        //filter(f.items, function(i) { return i.title.indexOf("PR: ") != 0 }); 
    38                         var re = /<a(?:\s+[^>]+)*?\s+href\s*=\s*["']?\s*http:\/\/rss\.rssad\.jp\/[^>]+>[\s\S]+?<\/a\s*>|<img(?:\s+[^>]+)*?\s+src\s*=\s*["']?\s*http:\/\/rss\.rssad\.jp\/[^>]+>/g; 
    39                         foreach(f.items, function(i) { 
    40                                 i.body = i.body.replace(re, ""); 
    41                         }); 
     38                        var re = /<a(?:\s+[^>]+)?\s+href\s*=\s*["']?\s*http:\/\/rss\.rssad\.jp\/[^>]+>[\s\S]+?<\/a\s*>|<img(?:\s+[^>]+)*?\s+src\s*=\s*["']?\s*http:\/\/rss\.rssad\.jp\/[^>]+>(?:<\/img\s*>)?/g; 
     39                        foreach(f.items, function(i) { i.body = i.body.replace(re, ""); }); 
    4240                }, 
    4341                "Userscripts.org - Trim Spam" : function(f) { 
     
    5654                }, 
    5755                "Flickr - Enlarge Thumbnails" : function(f) { // http://userscripts.org/scripts/show/14809 
    58                         if (doneIDs.indexOf(f.subscribe_id) > -1 || 
    59                             f.channel.link.indexOf("http://www.flickr.com/") != 0) return; 
     56                        if (f.channel.link.indexOf("http://www.flickr.com/") != 0) return; 
    6057 
    6158                        var re = /_m(?=\.(?:jpe?g|gif|png)")|\s+(?:width|height)="\d+"/g; 
     
    7168                }, 
    7269                "4U - Enlarge Thumbnails" : function(f) { // http://d.hatena.ne.jp/Constellation/20080327/1206633302 
    73                         if (doneIDs.indexOf(f.subscribe_id) > -1 || 
    74                             f.channel.link != "http://4u.straightline.jp/") return; 
     70                        if (f.channel.link != "http://4u.straightline.jp/") return; 
    7571 
    7672                        var re = /(?:\/m){2}(?=_)/; 
     
    8076                        if (! /^http:\/\/[^.]+\.blog\d+\.fc2\.com\//.test(f.channel.link)) return; 
    8177 
    82                         var re = /(<img(?:\s+[^>]+)*?\ssrc="[^"]+)s(\.jpg")/g; 
     78                        var re = /(<img(?:\s+[^>]+)?\ssrc="[^"]+)s(\.jpg")/g; 
    8379                        foreach(f.items, function(i) { i.body = i.body.replace(re, "$1$2"); }); 
    8480                }, 
     
    8682                        if (f.channel.link.indexOf("//knuttz.net/") < 0) return; 
    8783 
    88                         var RE = /<a(?:\s+[^>]+)*?\s+href="([^"]+)"[^>]*>.*?Clic?k\s+Here[\S\s]*?<\/a\s*>/i; 
     84                        var RE = /<a(?:\s+[^>]+)?\s+href="([^"]+)"[^>]*>.*?Clic?k\s+Here[\S\s]*?<\/a\s*>/i; 
    8985                        foreach(f.items, function(i) { 
    9086                                if (! RE.test(i.body)) return; 
     
    9692                        if (f.channel.link != "http://www.gizmodo.jp/") return; 
    9793 
    98                         var re = /<a(?:\s+[^>]+)*?\s+href="([^"]+)"[^>]*>\u7D9A\u304D\u3092\u8AAD\u3080<\/a>/; 
     94                        var re = /<a(?:\s+[^>]+)?\s+href="([^"]+)"[^>]*>\u7D9A\u304D\u3092\u8AAD\u3080<\/a>/; 
    9995                        foreach(f.items, function(i) { 
    10096                                if (! re.test(i.body)) return; 
     
    107103                            f.channel.link != "http://slashdot.jp/") return; 
    108104 
    109                         var re = /<a(?:\s+[^>]+)*?\s+href="([^"]+)"[^>]*>Read more of this story<\/a>/; 
     105                        var re = /<a(?:\s+[^>]+)?\s+href="([^"]+)"[^>]*>Read more of this story<\/a>/; 
    110106                        foreach(f.items, function(i) { 
    111                                 if (! re.test(i.body)) return; 
    112                                 i.link = RegExp.$1; 
     107                                if (re.test(i.body)) i.link = RegExp.$1; 
    113108                        }); 
    114109                }, 
     
    124119                        if (! (f.items[0] && re.test(f.items[0].link))) return; 
    125120 
    126                         foreach(f.items, function(i) { i.link = i.link.replace(re, "").replace(/\?(?=#|$)/, ""); }); 
     121                        foreach(f.items, function(i) { 
     122                                i.link = i.link.replace(re, "").replace(/\?(?=#|$)/, ""); 
     123                        }); 
    127124                }, 
    128125                "Trim Spaces to Compact Items" : function(f) { 
    129126                        foreach(f.items, function(i) { 
    130                                 i.body = i.body.replace(/(^|<[ap](?:\s+[^>]*)?>)(?:\s|<br(?:\s+[^>]*|\s*\/?)>)+|(?:\s|<br(?:\s+[^>]*|\s*\/?)>)+($|<\/[ap]\s*>)|<a(?:\s+[^>]*)?>(?:\s|<br(?:\s+[^>]*|\s*\/?)>)*<\/a\s*>/ig, "$1$2") 
    131                                                .replace(/<(p(?:re)?)(?:\s+[^>]*)?>(?:\s|<br(?:\s+[^>]*|\s*\/?)>)*<\/\1\s*>/ig, ""); 
     127                                i.body = i.body.replace(/(^|<[ap](?:\s+[^>]*)?>)(?:\s|<br(?:\s+[^>]*)?>(?:<\/br>)?)+|(?:\s|<br(?:\s+[^>]*)?>(?:<\/br>)?)+($|<\/[ap]>)|<a(?:\s+[^>]*)?>(?:\s|<br(?:\s+[^>]*)?>(?:<\/br>)?)*<\/a>/ig, "$1$2") 
     128                                               .replace(/<(p(?:re)?)(?:\s+[^>]*)?>(?:\s|<br(?:\s+[^>]*)?>(?:<\/br>)?)*<\/\1>/ig, ""); 
    132129                        }); 
    133130                } 
     
    135132 
    136133        const preFilters = { 
    137                 "Flickr - Enlarge and Prefetch Thumbnails" : function(f) { // http://userscripts.org/scripts/show/14809 
    138                         if (doneIDs.indexOf(f.subscribe_id) > -1 || 
    139                             f.channel.link.indexOf("http://www.flickr.com/") != 0) return; 
     134                "Flickr - Prefetch Thumbnails" : function(f) { // http://userscripts.org/scripts/show/14809 
     135                        if (f.channel.link.indexOf("http://www.flickr.com/") != 0) return; 
    140136 
    141                         doneIDs.push(f.subscribe_id); 
    142                         var re = /([^"]+?)_m(\.(?:jpe?g|gif|png))(?=")|\s+(?:width|height)="\d+"/g; 
     137                        var re = /([^"]+?)_m(\.(?:jpe?g|gif|png))(?=")/g; 
    143138                        foreach(f.items, function(i) { 
    144                                 i.body = i.body.replace(re, "$1$2"); 
    145                                 new this.Image().src = RegExp.$1 + RegExp.$2; 
     139                                if (re.test(i.body)) new this.Image().src = RegExp.$1 + RegExp.$2; 
    146140                        }); 
    147141                }, 
    148                 "4U - Enlarge and Prefetch Thumbnails" : function(f) { 
    149                         if (doneIDs.indexOf(f.subscribe_id) > -1 || 
    150                             f.channel.link != "http://4u.straightline.jp/") return; 
     142                "4U - Prefetch Thumbnails" : function(f) { 
     143                        if (f.channel.link != "http://4u.straightline.jp/") return; 
    151144 
    152                         doneIDs.push(f.subscribe_id); 
    153145                        var re = /([^"]+?)(?:\/m){2}(\w+\.(?:jpe?g|gif|png))(?=")/; 
    154146                        foreach(f.items, function(i) { 
    155                                 i.body = i.body.replace(re, "$1/l/l$2"); 
    156                                 new this.Image().src = RegExp.$1 + "/l/l" + RegExp.$2; 
     147                                if (re.test(i.body)) new this.Image().src = RegExp.$1 + "/l/l" + RegExp.$2; 
    157148                        }); 
    158149                }, 
    159150                "Prefetch Images from Secure Sites" : function(f) { 
    160151                        var link = f.channel.link; 
    161                         if (doneIDs.indexOf(f.subscribe_id) > -1 || 
    162                             link != "http://ffffound.com/" && 
     152                        if (link != "http://ffffound.com/" && 
    163153                            ! /^http:\/\/[^.]+\.tumblr\.com/.test(link)) return; 
    164154 
    165                         doneIDs.push(f.subscribe_id); 
    166155                        var re = /http:\/\/(?:img\.ffffound|data\.tumblr)\.com\/[\w\/-]+?\.(?:jpe?g|gif|png)/; 
    167156                        foreach(f.items, function(i) { 
    168                                 if (re.test(i.body)) 
    169                                         new this.Image().src = RegExp.lastMatch; 
     157                                if (re.test(i.body)) new this.Image().src = RegExp.lastMatch; 
    170158                        }); 
    171159                } 
    172160        }; 
    173161 
     162        register_hook("BEFORE_SUBS_LOAD", function() { 
     163                filteredIDs = preFilteredIDs = []; 
     164        }); 
     165 
    174166        register_hook("BEFORE_PRINTFEED", function(feed) { 
    175                 if (! subs_item(feed.subscribe_id).unread_count) return; 
     167                if (filteredIDs.include(feed.subscribe_id) || 
     168                    ! subs_item(feed.subscribe_id).unread_count) return; 
    176169 
     170                filteredIDs.push(parseInt(feed.subscribe_id)); 
    177171                for (var filter in filters) 
    178172                        filters[filter](feed); 
    179173        }); 
    180174 
    181 /*      preInvoke(get_unread.cache, "set", function(sid, feed) { // http://userscripts.org/scripts/show/14809 
    182                 if (typeof feed == "object" && subs_item(feed.subscribe_id).unread_count) 
    183                         for (var filter in preFilters) 
    184                                 preFilters[filter](feed); 
    185         }); */ 
     175if (false) 
     176        preInvoke(get_unread.cache, "set", function(sid, feed) { // http://userscripts.org/scripts/show/14809 
     177                if (typeof feed != "object" || preFilteredIDs.include(feed.subscribe_id)) return; 
     178 
     179                preFilteredIDs.push(parseInt(feed.subscribe_id)); 
     180                for (var filter in preFilters) 
     181                        preFilters[filter](feed); 
     182        }); 
    186183} 
    187184 
     
    191188} 
    192189 
    193 function preInvoke(target, name, f) { // http://userscripts.org/scripts/show/14809 
     190function preInvoke(target, name, f) { 
    194191        var _target = target[name]; 
    195192        target[name] = function() { 
     
    198195        }; 
    199196} 
     197 
     198Array.prototype.include = function(id) { return this.indexOf(parseInt(id)) > -1 };