Skip to content

Instantly share code, notes, and snippets.

@kerminz
Last active April 27, 2019 10:46
Show Gist options
  • Save kerminz/f14e18db0bf1a31143779232f9e81f61 to your computer and use it in GitHub Desktop.
Save kerminz/f14e18db0bf1a31143779232f9e81f61 to your computer and use it in GitHub Desktop.
Code aus Youtube Video SPA + Flickering
javascript: (function(e, s) {
e.src = s;
e.onload = function() {
jQuery.noConflict();
};
document.head.appendChild(e);
})(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js')
var event = new Event('abtest');
// Listen for the event.
window.addEventListener('abtest', function (e) {
console.log("AB Test running...");
console.log("Sign In Page");
document.querySelector("#__layout > div > main > form > div:nth-child(1) > label").innerText = "E_MAIL FLICKER?"
document.querySelector("#__layout > div > main > form > div.field.margin-top-lg > div > button").style.backgroundColor = "red";
jQuery("main").append(myvar);
}, false);
function waitForElement(selector, target, callback) {
// observer target node
var target = document.querySelector(target);
// create new observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var addedNodes = mutation.addedNodes;
for (var i=0; i < addedNodes.length; i++) {
var node = addedNodes[i];
if (node.matches && node.matches(selector)) {
callback();
//observer.disconnect();
}
}
});
});
// observer config
var config = { childList: true, subtree: true };
// start with observervation
if (target) {
observer.observe(target, config);
}
}
var myvar = '<form class="box is-large" data-op-form-id="0"><div class="field"><label class="label">'+
' Email address'+
' </label> <div class="control has-icons-right"><input type="email" autocomplete="on" placeholder="[email protected]" required="required" class="input is-danger" data-op-id="0"> <!----> <span class="icon is-right has-text-danger"><i class="mdi mdi-alert-circle mdi-24px"></i></span> <!----></div> <p class="help is-danger">Please fill in this field.</p></div> <div class="field"><label class="label">'+
' Password'+
' </label> <div class="control is-clearfix"><input type="password" autocomplete="on" placeholder="Your password" required="required" class="input"> <!----> <!----> <!----></div> <!----></div> <label tabindex="0" class="b-checkbox checkbox margin-top-md"><input type="checkbox" true-value="true" value="false"> <span class="check"></span> <span class="control-label">Remember me</span></label> <div class="field margin-top-lg"><div class="control"><button formnovalidate="formnovalidate" class="button is-primary is-medium is-fullwidth">Sign in</button></div></div> <div class="field margin-top-sm has-text-centered"><a class="t5">Forgot password?</a></div></form>';
waitForElement("main.is-narrow", "body", function() {
window.dispatchEvent(event);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment