Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loginToSite(user, password) {
- var Request = require("sdk/request").Request;
- var doLogin = Request(
- {
- url: "https://website.com/login/index.php",
- contentType: "application/x-www-form-urlencoded",
- content: "username=xxxx&password=xxxx&remember=1",
- onComplete: function(response) {
- console.log(response.text);
- }
- }
- );
- doLogin.post();
- }
- function checkLoginStatus(tab) {
- //TODO Actually check if the tab is logged in, currently assume it's not
- loginToSite(0,0);
- }
- // Listens for tabs and checks each loaded tab if it's the website
- tabs.on("ready", function(tab) {
- var tabUrl = tab.url.toLowerCase();
- if(tabUrl.contains("website.com")) {
- console.log("Not connected to website.com, running login procedure");
- checkLoginStatus(tab);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement