GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2010-01-18 21:28:24

xDanielx
Member
Registered: 2009-01-02
Posts: 38

GMC search automator in Chrome

I don't post too much on the GMC these days, but I have this weird addiction to keeping track of old discussions, so I often search my own name in the advanced search form. Problem is, I do this a lot and, though I have the advanced search bookmarked, I don't like all the typing. Other problem is, I needed an excuse to try out Chrome's extension framework!

The solution turned out to be pretty trivial. We just create a directory with two text files:

manifest.json wrote:

{
    "name": "GMC Search Form Automator",
    "version": "1.0",
    "description": "Automatically fills out and submits the Game Maker Community advanced search form.",
    "content_scripts": [
        {
            "matches": ["http://*.gmc.yoyogames.com/index.php*act=Search&mode=adv"],
            "js": ["gmcs.js"]
        }
    ]
}

gmcs.js wrote:

document.getElementById("entered_name").value = "YOUR USERNAME HERE";
document.sForm.submit();

Then from the extensions page, expand "Developer mode" and click "Load unpacked extension." Select the directory containing the extension. All done!

Note that the extension framework hasn't made its way into the stable release yet, so this requires the beta version.

Offline

#2 2010-01-18 21:38:01

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: GMC search automator in Chrome

Very interesting!

If you can get your extension to work with my username, you're golden. Hint: My username is only 3 characters so it's not a valid search term. The only reason I'm a moderator at GMC is to work my way up to Admin status so I can change the search limits. *shhhh* Don't tell!

I've been wanting to do something like this extension myself. I can think of a few moderation tools that could be built with GreaseMonkey / Chrome extensions. 95% of my GMC moderation is extremely tedious and could benefit from some automation.


Abusing forum power since 1986.

Offline

#3 2010-01-18 23:00:26

xDanielx
Member
Registered: 2009-01-02
Posts: 38

Re: GMC search automator in Chrome

Hm, it seems to work for me... are you sure you're using "Filter by Member Name" as opposed to "Search by Keywords"?

The other thing I'm planning to automate is authentication. Wouldn't it be cool if login screens went away the moment they popped up? Especially for websites with "security features" like autocomplete=off to prevent browsers from helping. Of course, this would mean storing clear text passwords on disk. But who would want to get into my PayPal account anyway? Not like they'd find any money there. whistle

Offline

#4 2010-01-18 23:11:29

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: GMC search automator in Chrome

I'm not looking for my own posts, I'm looking for posts that mention me. Yes, I'm that big of an egomanic. There's always Google, of course. I rarely use the GMC's search to be honest unless I'm looking for something specific said by a specific member.

Do you know if it is possible to script something that can submit multiple forms and act on dynamic content in multiple pages using a single action such as clicking an embedded link placed on a page by a script?

I'll give you an example of what I mean. When I moderate the GMC's Tutorials and Examples forum, more often than not new topics are not correctly formated. I'd love to be able to click a button or link to (1) Compose and send a standard message to the topic starter with (2) user name and subject inserted based on the topic and (3) quotes within the message a copy of the contents of the topic (including BB Code), and then (4) deletes the topic.

To do this manually means:
(1) Click Edit at the bottom of the topic
(2) Select All to get original contents of the topic as submitted.
(3) Copy contents to Clipboard
(4) Click "Send Message" in member name drop-down menu
(5) Start composing the message by pasting topic contents into a Quote box
(6) In second browser tab, load my Control Panel
(7) Copy to clipboard generic boilerplate rejection message from Personal Notepad
(8) Switch back to first tab, insert rejection message
(9) Replace MEMBERNAME with the member's name (copy and paste from PM "To" field)
(10) Switch back to second tab, copy to clipboard the topic name from recently read topics list.
(11) Switch back to first tab, paste topic title into subject line
(12) Send message (saving copy)
(13) Close tab (switching to second tab), click link back to topic.
(14) Delete topic

That's the fastest way I've found to properly reject a GMC Tutorial and Examples topic. Ridiculous. There are other similarly protracted procedures for common moderation duties.

I'm not asking you to write this, I'm just wondering if it is feasible with a single browser script.


Abusing forum power since 1986.

Offline

#5 2010-01-19 00:07:58

xDanielx
Member
Registered: 2009-01-02
Posts: 38

Re: GMC search automator in Chrome

I don't know the architecture too well, but I see a few approaches --

- You could have a page action (essentially a button in the URL bar that shows up for certain pages and does something when pressed). This would be tedious because the script which is triggered upon clicks can't access the DOM of the current page directly, so you'd need to set up a "content script" (as I understand it, these are loaded for each page and can access the DOM of the page) and have the two components communicate with messages.

- You could have a content script associated with tutorial pages which inserts an html button into the page. It might look something like

Expand<a href="javascript: a lot of code involving XMLHttpRequest">Reject this tutorial</a>

I don't think browsers will allow external scripts to make XMLHttpRequest calls to the gmc.yoyogames.com domain, so you might need to stuff all the javascript in the link.

- Actually open the pages using window.location.href="some URL" calls, as if you were clicking the buttons. I believe content scripts themselves are not persistent (as in they go out of scope when pages do), but you could use a "background script" to keep track of the state of the automation.

I think the third approaches would be most viable, but I might be overlooking some difficulty since, again, I don't know the architecture too well.

Offline

#6 2010-01-19 00:55:53

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: GMC search automator in Chrome

I don't think any of them are viable. HTTP is inherently stateless. A background script would necessarily have to run in a separate page, and separate pages shouldn't be able to communicate with each other when things are working correctly. Normally any state tracking has to be handled with cookies (probably inaccessible in this case) or PUT/GET via an external script, which is a problem when XSS protection is in place (which it is).

It's a complex problem. Might be solvable with a chain of scripts and some AJAX. If I wasn't dealing with such large chunks of data I could use GET magic in the URL. Also, if the clipboard was exposed to Javascript it could simplify things, but it's not outside of ill-behaved IE.

I know there are also some powerful macro apps out there that can do this, I just don't want to mess with them. I'm a little leery of them because they tend to be used for hacking web sites and I'm not sure I trust the source.


Abusing forum power since 1986.

Offline

#7 2010-01-19 04:16:41

xDanielx
Member
Registered: 2009-01-02
Posts: 38

Re: GMC search automator in Chrome

I think you could keep track of state with Chrome's background pages feature (though it does introduce a big layer of complexity).

Offline

#8 2010-01-19 10:26:24

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: GMC search automator in Chrome

Ahhh, interesting. Clearly I need to spend some time reading the docs. Thanks for that.


Abusing forum power since 1986.

Offline

#9 2010-01-21 01:21:27

xDanielx
Member
Registered: 2009-01-02
Posts: 38

Re: GMC search automator in Chrome

It had to happen... yet another GML highlighter! smile

Offline

Board footer

Powered by FluxBB