Created
July 18, 2009 08:21
Revisions
-
snaka revised this gist
Jul 25, 2009 . 1 changed file with 48 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,40 +8,32 @@ // @license MIT license (http://www.opensource.org/licenses/mit-license.php) // ==/UserScript== (function() { const DATABASE = 'http://wedata.net/databases/SPAM_Sites'; const STORE_KEY = 'jaroCacheInofo'; const CACHE_EXPIRE = 1000 * 60 * 60 * 24; var sites = []; var localSetting = [ /* (example) '^http:\/\/\w+\.designlinkdatabase\.net', '^http:\/\/\w+\.thumbnailcloud\.net', */ ]; // If you want to negate the filter, set the pattern of the site names here. var antiFilter = [ /* (example) /^http:\/\/\w+\.designlinkdatabase\.net/ */ ]; // // main logic // if (sites = getCache()) { GM_log("USE CACHE"); setOpacity(sites); } else { GM_log("REQUEST TO REMOTE"); GM_xmlhttpRequest({ method: 'GET', url: DATABASE + '/items.json', onload: function(res) { try { sites = [i.data.url_pattern for each(i in eval(res.responseText))]; @@ -52,16 +44,9 @@ }); } function getCache() { var cacheInfo = eval(GM_getValue(STORE_KEY)); if (!cacheInfo || cacheInfo.expire < new Date) { return null; } return cacheInfo.sites; @@ -76,12 +61,13 @@ } function setOpacity(sites, doc) { mergedSites = sites.concat(localSetting); $X('//a[@class="l"]', doc).forEach(function(ele) { var link = ele.href; if (isExcepts(link)) { return; } if (isTarget(link, mergedSites)) { ele.parentNode.parentNode.style.opacity = '0.3'; } }); @@ -95,4 +81,37 @@ return sites.some(function(i) { return url.match(i) }); } // // Register menu command // GM_registerMenuCommand('jaro - clear cache', clearCache); function clearCache() { GM_setValue(STORE_KEY, 'null'); alert("Cache cleared."); } GM_registerMenuCommand('jaro - go to Wedata', gotoWedata); function gotoWedata() { window.open(DATABASE + '/items'); } // // Register page handler // if (window.AutoPagerize) { registerPageHandler(); } else { window.addEventListener('GM_AutoPagerizeLoaded', registerPageHandler, false); } function registerPageHandler() { window.AutoPagerize.addFilter(function(pages) { pages.forEach(function(page) { setOpacity(sites, page); }); }); } })(); -
snaka revised this gist
Jul 22, 2009 . 1 changed file with 85 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,18 +4,95 @@ // @require http://gist.github.com/raw/3242/9dc0cdee5e975d275c7ab71f581d272eb316674f/dollarX.js // @include http://www.google.com/* // @include http://www.google.co.jp/* // @author [email protected] // @license MIT license (http://www.opensource.org/licenses/mit-license.php) // ==/UserScript== (function() { const STORE_KEY = 'jaroCacheInofo'; const CACHE_EXPIRE = 1000 * 60 * 60 * 24; var sites = []; var local_setting = [ /* (example) '^http:\/\/\w+\.designlinkdatabase\.net', '^http:\/\/\w+\.thumbnailcloud\.net', */ ]; // If you want to negate the filter, set the pattern of the site names here. var antiFilter = [ /* (example) /^http:\/\/\w+\.designlinkdatabase\.net/ */ ]; GM_registerMenuCommand('jaro - clear cache', clearCache); if (window.AutoPagerize) { window.AutoPagerize.addDocumentFilter(function(doc) { setOpacity(sites, doc); }); } if (sites = getCache()) { GM_log("USE CACHE"); setOpacity(sites); } else { GM_log("REQUEST TO REMOTE"); GM_xmlhttpRequest({ method: 'GET', url: 'http://wedata.net/databases/SPAM_Sites/items.json', onload: function(res) { try { sites = [i.data.url_pattern for each(i in eval(res.responseText))]; setOpacity(sites); storeCache(sites); } catch(e) { } } }); } function clearCache() { GM_setValue(STORE_KEY, 'null'); } function getCache() { var cacheInfo = eval(GM_getValue(STORE_KEY)); if (!cacheInfo) { return null; } if (cacheInfo.expire < new Date) { return null; } return cacheInfo.sites; } function storeCache(sites) { var cacheInfo = { expire: new Date((new Date()).getTime() + CACHE_EXPIRE), sites: sites }; GM_setValue(STORE_KEY, cacheInfo.toSource()); } function setOpacity(sites, doc) { mergedSites = sites.concat(local_setting); $X('//a[@class="l"]', doc).forEach(function(ele) { if (isExcepts(ele.href)) { return; } if (isTarget(ele.href, mergedSites)) { ele.parentNode.parentNode.style.opacity = '0.3'; } }); } function isExcepts(url) { return antiFilter.some(function(i) { return url.match(i) }); } function isTarget(url, sites) { return sites.some(function(i) { return url.match(i) }); } })(); -
snaka revised this gist
Jul 19, 2009 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,15 +8,13 @@ (function() { const sites = [ /^https?:\/\/\w+\.designlinkdatabase\.net/, /^https?:\/\/\w+\.thumbnailcloud\.net/, ]; $X('/html/body/div[4]/div/ol/li/h3/a').forEach(function(ele){ sites.forEach(function(site) { if (ele.href.match(site)) ele.parentNode.parentNode.style.opacity = '0.3' }); }); -
snaka revised this gist
Jul 18, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ // ==/UserScript== (function() { const sites = [ /^https?:\/\/\w+\.designlinkdatabase\.net/, ]; $X('/html/body/div[4]/div/ol/li/h3/a').forEach(function(ele){ -
snaka created this gist
Jul 18, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ // ==UserScript== // @name jaro // @namespace http://d.hatena.ne.jp/snaka72/ // @require http://gist.github.com/raw/3242/9dc0cdee5e975d275c7ab71f581d272eb316674f/dollarX.js // @include http://www.google.com/* // @include http://www.google.co.jp/* // ==/UserScript== (function() { const sites = [ /^https?:¥/¥/¥w+¥.designlinkdatabase¥.net/, ]; $X('/html/body/div[4]/div/ol/li/h3/a').forEach(function(ele){ sites.forEach(function(site) { if (ele.href.match(site)) { [ele.parentNode, ele.parentNode.parentNode].forEach(function(ele){ with(ele){ style.opacity = '0.3' }}); } }); }); })();