Created
April 11, 2012 10:55
-
-
Save poochin/2358630 to your computer and use it in GitHub Desktop.
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 characters
| ### | |
| // ==UserScript== | |
| // @name Default values | |
| // @match http://*/* | |
| // @version 1.0.0 | |
| // @description フォームの初期値を設定します | |
| // | |
| // @author poochin | |
| // @license MIT | |
| // @updated 2012-01-22 | |
| // @updateURL https://github.com/poochin/chrome/raw/master/userscript/defaultvalues.user.js | |
| // ==/UserScript== | |
| ### | |
| # match http://*/* の部分でコメントアウトの閉じ込みの文法エラーが出る | |
| (-> | |
| ustomvalues = [ | |
| match: /^http:\/\/www\.tumblr\.com\/new\/.*/, | |
| values: [{selector: '#post_state', value: 1,}], | |
| , | |
| match: /^http:\/\/www\.tumblr\.com\/reblog\/.*/, | |
| values: [{selector: '#post_state', value: 1,}], | |
| ] | |
| replacement = -> | |
| for i in [0...customvalues.length] | |
| custom = customvalues[i] | |
| match = custom.match | |
| values = custom.values | |
| if window.location.href.match match | |
| for j in [0...values.length] | |
| selector = values[j].selector | |
| value = values[j].value | |
| objs = window.documetn.querySelectorAll selector | |
| for n in [0...objs.length] | |
| objs[n].value = value | |
| if window.document.body? | |
| replacement | |
| else | |
| window.document.addEventListener 'DOMContentLoaded', replacement, false | |
| )() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment