-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle_voice_forward.user.js
63 lines (59 loc) · 1.88 KB
/
google_voice_forward.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ==UserScript==
// @name Google Voice Forward
// @namespace aljgom
// @version 0.1
// @description Automatically enable/disable text message forwarding by doing a web request to check which one it should chose
// sends a text message to confim the change using a PHP google voice API in the backend
// @match https://www.google.com/voice/b/0#phones
// ==/UserScript==
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==1) { }
if (xmlhttp.readyState==4 && xmlhttp.status==200){
checkForward(xmlhttp.responseText);
loadXMLDoc();
}
}
xmlhttp.open("POST","http://web.engr.illinois.edu/~gomez14/googleVoiceForward.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
txt=""; //"1="+document.getElementById('add').value +
xmlhttp.send(txt);
}
function checkForward(txt){
checkbox=document.getElementsByName("gc-sms-enabled2-8")[0];
if(txt != ""){
checkbox.click();
sendMessage(checkbox.checked,txt);
}
}
function sendMessage(msg,number){
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==1) { }
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
}
}
xmlhttp.open("POST","http://web.engr.illinois.edu/~gomez14/send_sms_post.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
txt="message="+msg+"&number="+number;
xmlhttp.send(txt);
}
loadXMLDoc();