GM_option

support tool for UserConfig.(library)

当前为 2015-04-26 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/9507/48605/GM_option.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
noisys
版本
1.00
创建于
2015-04-26
更新于
2015-04-26
大小
22.4 KB
许可证
http://creativecommons.org/licenses/by-nc-sa/4.0/




Work on Greasemonkey(Not support Scriptish)


---------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------
script nameGM_option
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
aboutThis script is the library to make a setting screen.
I made this support tool in order to make more easily.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[How to use]Sample code is end of this Script.


If savedata is none....?
first start-up or delete savedata
This script make GM_option window and save default.
next time
This script never make GM_option window without running open-function.


start function----------------------------------------------
GM_option.open(String,String,Array);

first String is HTML Tag(style or script or etc...)
second String is HTML Tag(in document.body).
third Array is optional,it's messages for dialog.

Message List
'save' - when click save button.
'reset' - when click reset button.(discard changes)
'clear' - when click clear button.(delete savedata)
'delete' - when click del button.(delete multiple)


user function--------------------------------------
At first,get user's settings.
GM_option.get();

return hashArray(Associative array).


HTML tag-------------------------------------------
use form inputs.
'name' is save-key.
'value' is save-data.

ex)
HTML tag is...
< input type="text" name="this_is_Key" value="this_is_Data" />

Save Data is...
{"this_is_Key":"this_is_Data"}


multiple text--------------------------------------
'name' is ****_multiple9999.(required)
9999 is number of array.(required)
'value' is default.(optional)
< button id="this_is_required"> is addButton.(required)

ex)
HTML tag is...
< input type="text" name="freeName_multiple2" value="data1" /> add

Save Data is...
{"freeName_multiple2":[["data1","data2"],["data3","data4"], and more ]}


select-multiple(HTML5)----------------------------
selected is checked.(optional)

ex)
HTML tag is...
< select name="selectName" multiple size=5>
< option name="optionName1" value="data1" >item1
< option name="optionName2" value="data2" selected>item2
< option name="optionName3" value="data3" >item3
< option name="optionName4" value="data4" selected>item4
< option name="optionName5" value="data5" >item5

Save Data is...
{"selectName":"{\"data2\":true,\"data4\":true}"}

To use...
var userSettings = GM_option.get();
var selectArray = JSON.parse(userSettings['selectName']);


addEventListener----------------------------------
'GM_option_loaded'

this event is dispatched...
when made GM_option frame (@first start-up)
when loaded User's Settings from GM_getValue (@next time)

ex)
window.addEventListener('GM_option_loaded',userFunction,false);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
history04/26/2015 - v1.0 release
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------