Created
April 30, 2024 13:57
-
-
Save i-sync/84d4f2847e17ba9e899ff79b1814063a to your computer and use it in GitHub Desktop.
Hook Sitecore API, Update NameValue key field set field width to 500px
This file contains 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 Modify Element Width | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Modify the width of a specific element on a webpage | |
// @author Michael | |
// @match https://sc.dev.local/* | |
// @require https://unpkg.com/[email protected]/dist/ajaxhook.min.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
ah.proxy({ | |
//请求发起前进入 | |
onRequest: (config, handler) => { | |
handler.next(config); | |
}, | |
//请求发生错误时进入,比如超时;注意,不包括http状态码错误,如404仍然会认为请求成功 | |
onError: (err, handler) => { | |
//console.log(err.type); | |
handler.next(err); | |
}, | |
//请求成功后进入 | |
onResponse: (response, handler) => { | |
if(response.config.url.indexOf('/sitecore/shell/applications/content-editor') > -1) { | |
// console.log("url:", response.config.url); | |
// rewrite response | |
// console.log(response.response); | |
var res = response.response.replace(/style=\\"width:150px\\"/g, 'style=\\\"width:500px\\\"'); | |
// console.log(res); | |
response.response = res; | |
} | |
handler.next(response); | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment