Create a gist now

Instantly share code, notes, and snippets.

@bz0 /tweet.js
Last active Oct 21, 2017

Embed
twitter.comでコンソールからツイートを実行する
var input = "test"; //入力内容
var div = document.querySelector("div#tweet-box-home-timeline div");
div.innerText = input;
var button = document.querySelector("button.tweet-action");
button.disabled = "";
button.click();
var create = {
token: function(tokenText){
var input = document.createElement('input');
input.name = 'authenticity_token';
input.type = 'hidden';
input.value = tokenText;
return input;
},
permalink: function(){
var input = document.createElement('input');
input.name = 'is_permalink_page';
input.type = 'hidden';
input.value = 'false';
return input;
},
lang: function(){
var input = document.createElement('input');
input.name = 'lang';
input.type = 'hidden';
input.value = 'ja';
return input;
},
place_id: function(){
var input = document.createElement('input');
input.name = 'place_id';
input.type = 'hidden';
input.value = '';
return input;
},
status: function(text){
var input = document.createElement('input');
input.name = 'status';
input.type = 'hidden';
input.value = text;
return input;
},
tagged_users: function(){
var input = document.createElement('input');
input.name = 'tagged_users';
input.type = 'hidden';
input.value = '';
return input;
}
}
var method = {
token: function (){
var input = document.querySelector("input[name=authenticity_token]");
var token = input.value;
return token;
},
form: function(tokenText, text){
var form = document.createElement('form');
form.action = '/i/tweet/create';
form.method = 'post';
form.target = 'tweet-post-iframe';
form.id = 'tweet-3rdparty-form';
var token = create.token(tokenText);
form.appendChild(token);
var permalink = create.permalink();
form.appendChild(permalink);
var lang = create.lang();
form.appendChild(lang);
var place_id = create.place_id();
form.appendChild(place_id);
var status = create.status(text);
form.appendChild(status);
var tagged_users = create.tagged_users();
form.appendChild(tagged_users);
return form;
},
tweet: function(form){
document.body.appendChild(form);
form.submit();
var form = document.getElementById('tweet-3rdparty-form');
form.parentNode.removeChild(form);
}
}
var text = "test"; //tweetする内容
var token = method.token();
var form = method.form(token, text);
method.tweet(form);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment