Feature requeset: Option to define in which website code shall be run (instead of everywhere) #1

Open
LionelMarbot opened this Issue Jan 23, 2015 · 2 comments

Projects

None yet

2 participants

@LionelMarbot

Hi,

Thank you for your plugin! It would be great if one could define where the code shall be run automatically, instead of everywhere.

Best would be to be able to define the URL (also using regular expression) per code snippet that is store in the extension.

Thank you!

Best,
Lionel

@jaakkytt
Owner

Hi and thanks for the feedback,

I'll consider adding the following script to be available in the global scope but currently didn't want to make that URL testing part of the UI since the use cases I ran into usually lead me to testing for different locations in one script block several times (related addresses on the same website).

What I'm currently running with is a separate code block for self defined helper and background scripts among of which is:

testLocation = function (pattern, callback) {
    if (new RegExp(pattern).test(window.location.href)) {
        if (arguments.length > 2) {
            callback.apply(null, Array.prototype.slice.call(arguments, 2));
        } else {
            callback();
        }
    }
};
@jaakkytt
Owner

Currently have some partial code to provide the functionality to define regular expression URL match as a first line of the code block as in the example below. Any better ideas?

#url google.com
document.body.style.background = 'blue';

Sadly lacking the time in the near feature to finish this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment