1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google+で自動的に投稿するスクリプト_elementはポスト全体を指定

Last updated at Posted at 2012-03-16
//関数:自動ポスト(ボタン一覧でのみ使用可能)
	function autopost(_element, _text){
		scrolllockstop = 1;
		try{
			var a = _element.parentNode.parentNode;
			var b = _element;	//ポスト全体
			while(1){
				a = a.nextSibling;
				try{
					if(a.getAttribute("role")=="button"){
						var c = document.createEvent("MouseEvents");
						c.initEvent("click", true, false);
						a.dispatchEvent(c);
						setTimeout(function(){
							var d = b.getElementsByTagName("div");
							var e = d.length;
							for (var f=0; f < e; f++) {
								if(d[f].id.match(reg_e)){
									try{
										var g = document.createEvent("TextEvent");
										g.initTextEvent ('textInput', true, true, null, _text);
										d[f].firstChild.firstChild.dispatchEvent(g);
										var g = document.createEvent("KeyboardEvent");
										g.initKeyboardEvent("keypress", true, false, window, 13, false, false, false, "", false);
										d[f].firstChild.firstChild.dispatchEvent(g);
									}catch( _error ){
										d[f].firstChild.firstChild.firstChild.contentDocument.body.innerHTML = _text+"<br>";
										var g = document.createEvent("KeyboardEvent");
										g.initKeyEvent ("keypress", true, true, window, false, false, false, false, 0, 13);
										d[f].firstChild.firstChild.firstChild.contentDocument.body.dispatchEvent(g);
										
									}
									
									var c = document.createEvent("MouseEvents");
									c.initEvent("mousedown", true, true);
									d[f].nextSibling.dispatchEvent(c);
									
									var c = document.createEvent("MouseEvents");
									c.initEvent("mouseup", true, true);
									d[f].nextSibling.dispatchEvent(c);
									break;
								}
							}
						}, 150);
						return;
					}
				}catch( _error ){
				}
			}
		}catch( _error ){
		}
	}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?