Created
October 4, 2014 20:30
-
-
Save gpoul/ea4c28c677528848df0b to your computer and use it in GitHub Desktop.
Drive-Now Fix for Chrome Password Manager compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fixDriveNow() { | |
// Are we logged in? | |
var loggedIn = document.getElementsByClassName("logout").length | |
if(!loggedIn) { | |
// Look for the password field | |
var passwordField = document.getElementsByName('password')[0] | |
if(passwordField) { | |
// If passwordField has a form associated with it, then the problem was fixed upstream | |
if(passwordField.form) { | |
console.log("Issue is already fixed.") | |
window.clearInterval(intervalID) | |
} else { | |
loginDiv = passwordField.parentNode | |
// Verify that this really is the correct node | |
if (loginDiv.childElementCount == 2 && loginDiv.firstElementChild.name == "email") { | |
var formElement = document.createElement('form') | |
while(loginDiv.firstChild) { | |
formElement.appendChild(loginDiv.firstChild.cloneNode()) | |
loginDiv.removeChild(loginDiv.firstChild) | |
} | |
loginDiv.appendChild(formElement) | |
window.clearInterval(intervalID) | |
console.log("Drive-Now page fixing done") | |
} else { | |
console.log("Due diligence failed: name=" + loginDiv.firstChild.name + " len=" + loginDiv.length + " loginDiv=" + loginDiv.innerHTML) | |
window.clearInterval(intervalID) | |
} | |
} | |
} else { | |
console.log("No password element found: " + passwordField) | |
} | |
} else { | |
console.log("We're logged in, so do nothing") | |
window.clearInterval(intervalID) | |
} | |
} | |
var intervalID = window.setInterval(fixDriveNow, 500) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Drive-Now Fix for Chrome Password Manager compatibility", | |
"version": "1.0", | |
"content_scripts": [ | |
{ | |
"matches": ["https://at.drive-now.com/*"], | |
"js": ["drivenow.user.js"], | |
"run_at": "document_start" | |
} | |
], | |
"manifest_version": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Starting with Chrome 46 this workaround should no longer be necessary as Chrome now includes a workaround to detect password fields outside form elements as part of Issue 451644