Skip to content

Instantly share code, notes, and snippets.

@poochin
Created April 11, 2012 10:55
Show Gist options
  • Select an option

  • Save poochin/2358630 to your computer and use it in GitHub Desktop.

Select an option

Save poochin/2358630 to your computer and use it in GitHub Desktop.
###
// ==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