Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function loginToSite(user, password) {
  2. var Request = require("sdk/request").Request;
  3.  
  4. var doLogin = Request(
  5. {
  6. url: "https://website.com/login/index.php",
  7. contentType: "application/x-www-form-urlencoded",
  8. content: "username=xxxx&password=xxxx&remember=1",
  9. onComplete: function(response) {
  10. console.log(response.text);
  11. }
  12. }
  13. );
  14.  
  15. doLogin.post();
  16. }
  17.  
  18. function checkLoginStatus(tab) {
  19. //TODO Actually check if the tab is logged in, currently assume it's not
  20. loginToSite(0,0);
  21. }
  22.  
  23. // Listens for tabs and checks each loaded tab if it's the website
  24. tabs.on("ready", function(tab) {
  25. var tabUrl = tab.url.toLowerCase();
  26. if(tabUrl.contains("website.com")) {
  27. console.log("Not connected to website.com, running login procedure");
  28. checkLoginStatus(tab);
  29. }
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement