Problem with sending GM_setValue() to another page with GM_getValue('eoUrl')

18 views
Skip to first unread message

Dave B

unread,
Nov 30, 2016, 12:48:04 AM11/30/16
to greasemonkey-users
var down = document.querySelector('a[href^="/get.php"]');

var anothernewItem = document.createElement("a");
anothernewItem.setAttribute("target", "_blank");
anothernewItem.setAttribute("title", "pcloud offline");
anothernewItem.setAttribute("href", "https://my.pcloud.com/");
var anothertextnode = document.createTextNode("Offline");
anothernewItem.appendChild(anothertextnode);
anothernewItem.setAttribute("style", "position: absolute; margin-top: 0px; margin-left: 0px; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAXVBMVEX///////8bytT///8fy9UbytQbytQfy9Ufy9UmzNYbytQgy9UizNUbytT///8bytQey9Ufy9Ugy9VG1NxB09sbytRg2uFS194bytT///9G1Nzx/Pzi+PpT19+c6OxZ7rqXAAAAGHRSTlMBG/AHxYAh49O3oWJBMRUR4bOLYV9RQz9fW5zbAAAAbUlEQVQY043MRxLCMBBE0WYkOQcyXybc/5hIhUuww2/3u2pGG1WdYV1VujcyG9ceWdmcM8jDK8bHE0LqCzMQF5Y7NOnNgeE7MATBMQ+fE/q9wCwNkDUetUAZPLVuxq+z3LWlqE9OctOumFL/9QYClwvt3NkDkgAAAABJRU5ErkJggg=='); background-color: rgb(241, 241, 241);");
down.parentNode.insertBefore(anothernewItem, down);

anothernewItem.click(function (event) {
GM_setValue("eoUrl", document.querySelector('a[href^="/get.php"]').href);
});
alert(GM_getValue("eoUrl"));

(function () {
if (location.href.indexOf("my.pcloud.com") != -1) {
//window.clearInterval(t);
curlink = GM_getValue('eoUrl');
if (curlink) {
var psc = setInterval(function () {
var upBtn = document.querySelector('div.upload_button');
if (upBtn) {
clearInterval(psc);
upBtn.click();
document.querySelector('span.remoteupload-ctrl').click();
var remotearea = document.querySelector('textarea.remotearea');
remotearea.value = curlink;
remotearea.nextSibling.click();
}
}, 500);
GM_deleteValue('eoUrl');
}
}
}
());


When I click the link in the first page, it opens pcloud page.
Error:
TypeError: Cannot read property 'href' of null

How can I handle this?

To get the variable 'eoUrl' from GM_setValue() in the first page.
And send it to opened pcloud page with GM_getValue('eoUrl') ?



Reply all
Reply to author
Forward
0 new messages