|
|
Hi, I'm searching/requesting a script for Greasmonkey that will read out the html-source-code of certain pages (BattleRepports of MMOG) and displayes a simple button at the bottom to submit.
Best regards Un1matr1x |
|
|
|
|
|
Hi dob, thx for the fast reply ;) I repleaced the "javascript;" with my page-link and tried it and it didn't work. Maybe there's a problem to "understand" because this board changes to much, eaven with Element to change and the sourcecode should be placed between the <textarea> </textarea> thx 4 help Best regards Un1 |
|
|
It doesn't need to be in a textarea because it's easier to just submit the html without needing to put it in a useless textarea for now. The server you post that info to will still see it as coming from an element named "kb" so it shouldn't matter.
|
|
|
I want to get it into the textarea beacause the user should be able to choose the options he want to and also fill the Names-Field. the url i set in is Store your BattleReport Best Regards Un1 |
|
|
It probably didn't work because the other input fields need to be filled too.
|
|
|
Sounds not that bad :) But I thought: a) it might be easier to build the script
So I requested the script as I did, but any working script would be great and I would be happy about it ;) |
|
|
var link = document.body.appendChild(document.createElement("a"));
with (link) {
style.cssText = "position: fixed; top: 2px; left: 2px; padding: 4px; background: #fff; color: navy; border: 1px solid navy";
href = "#";
textContent = "Send";
addEventListener("click", function() {
GM_xmlhttpRequest({
url: "http://kb.un1matr1x.de/save.php?lang=en",
method: "post",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: "username=YOURUSERNAME&userally=&titel=" + encodeURIComponent(prompt('Title:') || 'TITLE') + "&privat_kb=false&time=false&koord=false&tech=false&style=0&kb=" + encodeURIComponent(document.body.innerHTML),
onload: function(e) {
GM_openInTab('http://kb.un1matr1x.de' + e.responseText.match(/<a href="\.(.+?)"[^>]+>Directlink for the BattleReport<\/a>/)[1]);
}
});
}, false);
}
|
|
|
Thanks Mikado, your script is working great ;) But I have two question (sry 4 that): Is it possible to open the url also and transmite then the data, because after submit them you normaly get a lil' text how you can find your submited report and how you can share this. And the second question:
So why not just have a link you can click, then it asks the username and submits? |
|
|
Edited code above. |
|
|
thx :) working Great |
|
|
Hi, it's me again ^.- the script itself works fine, I use: // ==UserScript==
// @name KB-Hosting
// @namespace KB-Hosting
// @include http://uni*.ogame.*/game/index.php?page=bericht&*&bericht=*
// @include http://uni*.ogame.*/game/index.php?page=combatreport*
// ==/UserScript==
var link = document.body.appendChild(document.createElement("a"));
with (link) {
style.cssText = "position: fixed; bottom: 2px; left: 2px; padding: 4px; text-decoration:none; color:#f1f1f1;font: 12px Verdana,Arial,SunSans-Regular,Sans-Serif;text-align:center; background:url(http://kb.un1matr1x.de/images/icons/hauptnavi_a.gif) no-repeat;height:29px;width:135px;"
href = "#";
textContent = "KB Speichern";
addEventListener("click", function() {
GM_xmlhttpRequest({
url: "http://kb.un1matr1x.de/save.php",
method: "post",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: "username=" + encodeURIComponent(prompt('Username:') || 'USERNAME') + "&userally=" + encodeURIComponent(prompt('Alliance:') || 'USERALLY') + "&titel=" + encodeURIComponent(prompt('Title:') || 'TITLE') + "&privat_kb=false&time=false&koord=false&tech=false&style=0&kb=" + encodeURIComponent(document.body.innerHTML),
onload: function(e) {
GM_openInTab('http://kb.un1matr1x.de' + e.responseText.match(/<a href="\.(.+?)"[^ >]+>Direktlink zum Kampfbericht<\/a >/)[1]);
}
});
}, false);
and after store a BattleRepport I've got "KB Speichern" at the bottom, because that's the Script-Button. Can I prevent this? And if I'm allowed to be impertinent, somebody might tell me how to make a radio-button input where you can select the "true/false" for the other attributes. But again I have to: Thx for any help provided here (and your answers are so damn fast) |
|
|
Unimatrix_0 wrote:I don't get what you mean. You don't want the link there after you submit it or what? Mikado, you shouldn't add an element to the page then edit it, it's slower to access the page every time instead of editing it locally then adding it. Unimatrix_0 wrote:That would require making a form and adding it to the page and all that... I just made some code to give you an ok/cancel (ok=true, cancel=false) box instead of the radios. http://pastebin.com/f575c6309 |
|
|
and after store a BattleRepport I've got "KB Speichern" at the bottom, because that's the Script-Button. Can I prevent this?I don't get what you mean. You don't want the link there after you submit it or what? The Button-Name ---
http://kb.un1matr1x.de/kb.php?show=4844&pw=54d1...= instead of: http://kb.un1matr1x.de/kb.php?show=4844&pw=54d1dc so you will get the error-message: Information |
|
|
Hmm try this: http://pastebin.com/f51c42d7a |
|
|
I'm sorry to tell, but now it doesn't even open the url and still has the "KB Speichern" stored also |
|
|
Hi, it's Unimatrix - again. After a lot Try&Error i found out what who it won't went wrong and work - only the "KB Speichern" at the end is still "alive" but i have an idea how to get ride of it. The "only" problem with this solution is i don't know how to make it. ^.- Is it possible to store the html-sourc-code in a var befor adding the submit-button and use the var to be send to my website? the script is now like: http://pastebin.com/m510113bd ps: the error is the multi-language-part of my site so i have to force one language with |
|
|
Oh, the submitted code includes the link from the script you mean? Try this... http://pastebin.com/f7e1eca6c
|
|
|
thx man with
link.addEventListener("click", function(e) {
e.currentTarget.parentNode.removeChild(e.currentTarget);
GM_xmlhttpRequest({
will it work perfect thanks @ll, specialy JoeSimmons |
|
|
Hi, after a lil' testing i made some changes to provide the script in several languages. Now my Question is, if (and how) i can improve the performace of the script: |
|
|
I see you use a ton of space with the languages. What I would do is make a JSON object (even though switch might be technically faster, json will be shorter).
|
|
|
Having big object with unused data actually looks worse than conditional declarations. I'd just replace if's with switch. |
|
|
I think it looks good, JSON is quick. I don't like to have a ton of vars, slows things down. |
|
|
thx 4 your great help ;) i made the changes you said and thats what's the result: If i think of yesterday i didn't even understand anything around GM-Scripts (only how to use *gg*) but now i know a lil' bit - that's the best out of this here ;) (and my users can easier my hosting-service) so all what left to say: thanks again €dit: it was heavy to find out that I have to put a |
|
|
You're welcome. One more small optimization that could be made, use if(Sprache=='org') Sprache='us'; if(Sprache=='info') Sprache='de'; if(Sprache=='com.es') Sprache='es'; if(Sprache=='onet.pl') Sprache='pl'; if(Sprache=='com.tr') Sprache='tr'; switch() executes about 15% faster and breaks down to simpler code in asm, so do this: switch(Sprache) {
case 'org': Sprache='us'; break;
case 'info': Sprache='de'; break;
case 'com.es': Sprache='es'; break;
case 'onet.pl': Sprache='pl'; break;
case 'com.tr': Sprache='tr'; break;
}
|