Skip to content

Instantly share code, notes, and snippets.

javascript:(function() {
const getInputElements = () => Array.from(document.getElementsByTagName('input'));
const getInfoCompletedElements = () => getInputElements().filter(x => x.type === 'hidden' && x.name.startsWith('infoCompleted'));
const getButtonElements = () => Array.from(document.getElementsByClassName('amznBtn'));
const getSubmitButtons = () => getButtonElements().filter(x => x.textContent === 'Submit');
getInputElements().forEach(function(x) { if(x.value === 'no') x.click(); });
console.warn('** getInfoCmpletedElements', getInfoCompletedElements());
getInfoCompletedElements().forEach(x => x.value = "1");
@ericblade
ericblade / gist:2cc866f32a17f7c9076713a4ace2fb4a
Created September 18, 2018 10:11
node.js 6+ function for erroring when accessing an undefined property on an object, useful for application constant includes and such
constants.js:
function disallowUndefinedAccess(obj) {
const handler = {
get(target, property) {
if (property in target) {
return target[property];
}
throw new ReferenceError(`Access unknown ${property.toString()}`);
},
/* An incredibly handy function to run several (probably related) Promises simultaneously,
* allowing for any given Promise to reject, results will be returned in an object with same key names as the input
*/
/* example:
* const x = {
* api1: () => callApi1(),
* api2: () => callApi2(),
* api3: () => callApi3(),
* };
@ericblade
ericblade / app.js
Created September 10, 2012 15:11
LINE 非公式 API を使ってログイン
var LINE = require('./line.js');
var line = new LINE();
var email = 'your email';
var password = 'your password';
line.login(email, password, function(error, result) {
if (error) {
return;
}
@ericblade
ericblade / EnyoPlatform.js
Created February 19, 2012 19:19
Enyo kind for handling platform specific info
/* Enyo Platform encapsulation. Include this FIRST in your depends.js. The
* first call you make to a function inside it will cause it to perform it's
* detection (in the setup function). If you are running in PhoneGap, and your
* app depends on accurate results in here, make sure that you are not running
* any code that depends on this module until after the "deviceready" PhoneGap
* event is fired.
*
* This prefers direct access to APIs whenever possible - although you CAN run
* webOS and WebWorks apps with PhoneGap, I'm trying to avoid going through any
* extra layers here.
this.log("Inbox Received");
i = inResponse.indexOf("<json><!")+14;
j = inResponse.lastIndexOf("></json>")-1;
inboxJSON = JSON.parse(inResponse.substring(i,j));
[{"messages":
{"b61af8a73da92c3fdd0b8fb90866d4cc1140b3cd":
{"id":"b61af8a73da92c3fdd0b8fb90866d4cc1140b3cd",
"phoneNumber":"+11341343434",
"displayNumber":"(734) 123-9456",
"startTime":"1314472446198",
"displayStartDateTime":"8/27/11 3:14 PM",
"displayStartTime":"3:14 PM",
"relativeStartTime":"23 minutes ago",
"note":"",