Skip to content

Instantly share code, notes, and snippets.

@tomoki
Created August 9, 2013 12:45
Show Gist options
  • Save tomoki/6193347 to your computer and use it in GitHub Desktop.
Save tomoki/6193347 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @id GooglePlusAutoFuu
// @name Google+ Automatic Fuu Extension
// @version 0.6.9
// @namespace AutoFuu
// @author Jackson Tan
// @description Add a Fuu button below each post to help you send a comment with Fuu expression automatically.
// @include https://plus.google.com/*
// @run-at document-end
// ==/UserScript==
function doClick(target) {
var e;
e = document.createEvent("MouseEvents");
e.initEvent("mousedown", true, true);
target.dispatchEvent(e);
e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
target.dispatchEvent(e);
e = document.createEvent("MouseEvents");
e.initEvent("mouseup", true, true);
target.dispatchEvent(e);
return target;
};
function doKeypress(target) {
var e = document.createEvent("KeyboardEvent");
e.initEvent("keypress", true, true, window, 0, 0, 0, 0, 0, "e".charCodeAt(0));
target.dispatchEvent(e);
return target;
};
function MyProcessPosts(node){
if(!node || !node.querySelector) return;
var cls = node.getAttribute("class");
if(cls === null) return;
if(cls === "a-f-e c-b c-b-M f8ocqf Ri07Rc TGieS"){
doClick(node);
}else if(cls === "ChZ7Rc Tg Sb"){
var comm = node.getElementsByClassName("Kj bI")[0];
var go = (node.innerHTML.indexOf("nexus") !== -1 ||
node.innerHTML.indexOf("Nexus") !== -1 ||
node.innerHTML.indexOf("NEXUS") !== -1) ||
node.innerHTML.indexOf("N7") !== -1;
if(go){
setTimeout(function() {
doClick(comm);
}, 1);
}
} else if(cls === "Up Cu"){
setTimeout(function() {
var text = node.getElementsByClassName("yd editable")[0];
var submit = node.getElementsByClassName("a-f-e c-b c-b-da c-b-E")[0];
text.innerHTML = "Nexus7がほしい!";
doKeypress(text);
doClick(submit);
},1);
}
}
//Handle newly added posts
document.body.addEventListener('DOMNodeInserted', function(e) {
// console.log(e);
if(!e) e = event;
MyProcessPosts(e.target);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment