Last active
March 7, 2022 04:47
-
-
Save broven/8eacdc57f2bbdebb6499351e4c67be9e to your computer and use it in GitHub Desktop.
tamperMonkey
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 switch fastSwitchRegion | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description switch 快速换区 | |
// @author metajs | |
// @match https://accounts.nintendo.com/profile/edit | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=nintendo.com | |
// @homepageURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e | |
// @updateURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e/raw/NintendoFastSwitch.user.js | |
// @downloadURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e/raw/NintendoFastSwitch.user.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Alternative to load event | |
document.onreadystatechange = function () { | |
if (document.readyState === 'complete') { | |
const $target = document.querySelector('[name=country_id]'); | |
$target.setAttribute('size', 200); | |
$target.setAttribute('style', 'height: 100vh'); | |
} | |
} | |
})(); |
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 淘宝购物车多件警告 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description 对购物车多件物品的进行高亮 | |
// @author metajs | |
// @require https://code.jquery.com/git/jquery-3.x-git.min.js | |
// @match https://cart.taobao.com/cart.htm* | |
// @grant none | |
// @homepageURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e | |
// @updateURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e/raw/TaobaoShoppingCartCountWarning.user.js | |
// @downloadURL https://gist.github.com/broven/8eacdc57f2bbdebb6499351e4c67be9e/raw/TaobaoShoppingCartCountWarning.user.js | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) { | |
var startTimeInMs = Date.now(); | |
(function loopSearch() { | |
if (document.querySelector(selector) != null) { | |
callback(); | |
return; | |
} | |
else { | |
setTimeout(function () { | |
if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs) | |
return; | |
loopSearch(); | |
}, checkFrequencyInMs); | |
} | |
})(); | |
} | |
const highLight = (element) => { | |
const highLightColor = 'red'; | |
element.css('color', highLightColor); | |
element.css('fontWeight', 'bold'); | |
element.css('borderWidth', '3px'); | |
element.parents('.J_ItemBody') | |
.css('border', `2px solid ${highLightColor}`) | |
}; | |
const findAndHighlight = () => { | |
const inputArr = $('.item-amount > input'); | |
$.each(inputArr, (_, _ipt) => { | |
const ipt = $(_ipt); | |
const val = ipt.val(); | |
if (+val !== 1) { | |
highLight(ipt); | |
} | |
}); | |
}; | |
const addWarningToCheckoutBtn = () => { | |
$.each($('.J_CheckBoxItem:checked'), (_, val) => { | |
const $el = $(val); | |
if (+$el.parents('.J_ItemBody') | |
.find('.item-amount>input') | |
.val() !== 1) { | |
$('.submit-btn>span').text('买多了!'); | |
} | |
}) | |
} | |
const bindEvent = () => { | |
setInterval(findAndHighlight, 1000); | |
setInterval(addWarningToCheckoutBtn, 1000); | |
$('.item-amount').on('click', findAndHighlight); | |
$('.item-amount>input').on('input', findAndHighlight); | |
} | |
waitForElementToDisplay('.item-amount>input', findAndHighlight, 200, 5000); | |
waitForElementToDisplay('.item-amount>input', bindEvent, 200, 5000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment