How to load chrome extension background script from remote server?

Multi tool use
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
How can i perform loading chrome extension background script from remote?
Is it passible? With eval or something? how to do this, if am hosting the script on remote digital ocean?
javascript


add a comment |
How can i perform loading chrome extension background script from remote?
Is it passible? With eval or something? how to do this, if am hosting the script on remote digital ocean?
javascript


can i load javascirpt in background script and execute it? i mean i can load code and use the thing likechrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linkedduplicate
describes this?
– luci
Nov 16 '18 at 14:54
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31
add a comment |
How can i perform loading chrome extension background script from remote?
Is it passible? With eval or something? how to do this, if am hosting the script on remote digital ocean?
javascript


How can i perform loading chrome extension background script from remote?
Is it passible? With eval or something? how to do this, if am hosting the script on remote digital ocean?
javascript


javascript


asked Nov 16 '18 at 14:38


luciluci
63
63
can i load javascirpt in background script and execute it? i mean i can load code and use the thing likechrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linkedduplicate
describes this?
– luci
Nov 16 '18 at 14:54
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31
add a comment |
can i load javascirpt in background script and execute it? i mean i can load code and use the thing likechrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linkedduplicate
describes this?
– luci
Nov 16 '18 at 14:54
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31
can i load javascirpt in background script and execute it? i mean i can load code and use the thing like
chrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linked duplicate
describes this?– luci
Nov 16 '18 at 14:54
can i load javascirpt in background script and execute it? i mean i can load code and use the thing like
chrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linked duplicate
describes this?– luci
Nov 16 '18 at 14:54
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31
add a comment |
1 Answer
1
active
oldest
votes
DISCLAIMER: Loading background scripts from a remote site is generally NOT recommended, as it gives the remote script a lot of control of the user's browser if not their whole machine.
But if you insist, you could do something like this.
manifest.json
{
...
"background": { "scripts": ["background.js"] },
"permissions": [ "http://www.yourwebiste.com/*" ],
...
}
background.js
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.yourwebiste.com/remotescript.js", false);
xhr.send();
let code = xhr.responseText;
eval(code);
Regardless... DON'T DO THIS! In the name of security, just don't. Unless you are experienced and understand the caveats, I would whole hardheartedly recommend you don't use this method as it might introduce the execution of foreign code that you might not have control over, i.e. the remote script.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339932%2fhow-to-load-chrome-extension-background-script-from-remote-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
DISCLAIMER: Loading background scripts from a remote site is generally NOT recommended, as it gives the remote script a lot of control of the user's browser if not their whole machine.
But if you insist, you could do something like this.
manifest.json
{
...
"background": { "scripts": ["background.js"] },
"permissions": [ "http://www.yourwebiste.com/*" ],
...
}
background.js
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.yourwebiste.com/remotescript.js", false);
xhr.send();
let code = xhr.responseText;
eval(code);
Regardless... DON'T DO THIS! In the name of security, just don't. Unless you are experienced and understand the caveats, I would whole hardheartedly recommend you don't use this method as it might introduce the execution of foreign code that you might not have control over, i.e. the remote script.
add a comment |
DISCLAIMER: Loading background scripts from a remote site is generally NOT recommended, as it gives the remote script a lot of control of the user's browser if not their whole machine.
But if you insist, you could do something like this.
manifest.json
{
...
"background": { "scripts": ["background.js"] },
"permissions": [ "http://www.yourwebiste.com/*" ],
...
}
background.js
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.yourwebiste.com/remotescript.js", false);
xhr.send();
let code = xhr.responseText;
eval(code);
Regardless... DON'T DO THIS! In the name of security, just don't. Unless you are experienced and understand the caveats, I would whole hardheartedly recommend you don't use this method as it might introduce the execution of foreign code that you might not have control over, i.e. the remote script.
add a comment |
DISCLAIMER: Loading background scripts from a remote site is generally NOT recommended, as it gives the remote script a lot of control of the user's browser if not their whole machine.
But if you insist, you could do something like this.
manifest.json
{
...
"background": { "scripts": ["background.js"] },
"permissions": [ "http://www.yourwebiste.com/*" ],
...
}
background.js
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.yourwebiste.com/remotescript.js", false);
xhr.send();
let code = xhr.responseText;
eval(code);
Regardless... DON'T DO THIS! In the name of security, just don't. Unless you are experienced and understand the caveats, I would whole hardheartedly recommend you don't use this method as it might introduce the execution of foreign code that you might not have control over, i.e. the remote script.
DISCLAIMER: Loading background scripts from a remote site is generally NOT recommended, as it gives the remote script a lot of control of the user's browser if not their whole machine.
But if you insist, you could do something like this.
manifest.json
{
...
"background": { "scripts": ["background.js"] },
"permissions": [ "http://www.yourwebiste.com/*" ],
...
}
background.js
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.yourwebiste.com/remotescript.js", false);
xhr.send();
let code = xhr.responseText;
eval(code);
Regardless... DON'T DO THIS! In the name of security, just don't. Unless you are experienced and understand the caveats, I would whole hardheartedly recommend you don't use this method as it might introduce the execution of foreign code that you might not have control over, i.e. the remote script.
answered Nov 16 '18 at 19:40
EyuelDKEyuelDK
1,63011121
1,63011121
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339932%2fhow-to-load-chrome-extension-background-script-from-remote-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
SehIw3,KWQjhQwDHhVfDG nVgt1 f,ZYx,bpDCDmXQOfYEM 9aX8MnToiLRdYPQd2PBnh 1pEvMPz
can i load javascirpt in background script and execute it? i mean i can load code and use the thing like
chrome.runtime.onMessage
inside that eval/ loaded script? will it work ? does linkedduplicate
describes this?– luci
Nov 16 '18 at 14:54
I'm removing the duplicate, since the linked question stackoverflow.com/questions/7781851/… talks specifically about content scripts, and this is specifically about background scripts.
– Xan
Nov 16 '18 at 15:23
It's possible by modifying content_security_policy but that's bad practice which will be deprecated in the future ManifestV3 extensions and it'll make your extension suspicious in the eyes of WebStore reviewers.
– wOxxOm
Nov 16 '18 at 15:31