If object does not have key, add it.
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/427473/937458/object_setDefault.js
// ==UserScript==
// @name object_setDefault
// @namespace bo.gd.an[at]rambler.ru
// @version 0.3
// @description If object does not have key, add it.
// @author Bogudan
// @license LGPLv3
// @include https://localhost/
// ==/UserScript==
Object.defineProperty (Object.prototype, 'setDefault', {
value : function (key, value) {
if (!(key in this))
this [key] = value;
}
});