Created
March 9, 2016 09:02
-
-
Save Random-Stack-Random-Day/b02f35154914884fb88d to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match */* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
(function () { | |
if (location.search === "?Edit=True") { | |
debugger | |
function getText (id, isNotCtl) { | |
return document.querySelector((isNotCtl? "" : "#ctl00_main_part_") + id).textContent.trim() | |
} | |
function check() { | |
if (!document.getElementById("ctl00_main_part_rptReviewKeywords_ctl01_lblKeyword")) { | |
return setTimeout(check, 500); | |
} | |
var data = { | |
keyword: getText("rptReviewKeywords_ctl01_lblKeyword"), | |
campaignType: getText("lblMessage"), | |
autoResponse: getText("rptReviewKeywords_ctl01_MT"), | |
alreadySubbed: getText("rptReviewKeywords_ctl01_lblOldMT"), | |
title: getText(".campaigncreator_ReviewAlingChange", true), | |
maxInteractionAutoResponse: getText("Div2") | |
}; | |
var $form = $("<form action='http://localhost:9000/add-data' method='post'>"); | |
Object.keys(data).forEach(function (c) { | |
$form.append("<input name='" + c + "' value='" + data[c] + "'></form>"); | |
}); | |
$form.submit(); | |
} | |
check(); | |
return; | |
} | |
if (!~location.href.indexOf("http://hub.commercetel.com/UI/NewAccountInfo")) { | |
return; | |
} | |
function getQueryVariable(variable) { | |
var query = window.location.search.substring(1); | |
var vars = query.split('&'); | |
for (var i = 0; i < vars.length; i++) { | |
var pair = vars[i].split('='); | |
if (decodeURIComponent(pair[0]) == variable) { | |
return decodeURIComponent(pair[1]); | |
} | |
} | |
console.log('Query variable %s not found', variable); | |
} | |
var itemNumber = parseInt(getQueryVariable("item_number")); | |
if (isNaN(itemNumber)) { return; } | |
console.log(">>> Item Number" + itemNumber); | |
var allElm = document.querySelectorAll("#tBodyReportMain tr"); | |
function checkLoaded () { | |
console.log("Check"); | |
if (document.getElementById("tBodyReportMain")) { | |
debugger | |
var elm = document.querySelectorAll("#tBodyReportMain tr")[itemNumber].children[1]; | |
console.log("> Click", elm); | |
setTimeout(function () { | |
elm.click(); | |
}, 2000); | |
clearInterval(interval); | |
} | |
} | |
var interval = setInterval(checkLoaded, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment