Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // contentscript.js:
- chrome.extension.sendRequest({}, function(responseText) {
- // .... ???? Function logic ????
- // Let's assume that the responseText contains the CSS url.
- var currentTheme = responseText + '.css';
- var style = document.createElement('link');
- style.type = "text/css";
- style.rel = "stylesheet";
- style.href = currentTheme;
- (document.head||document.documentElement.firstElementChild).appendChild(style);
- });
- // background page:
- chrome.extension.onRequest.addListener(function(request, sender, callback) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if(xhttp.readystate == 4) {
- callback(xhttp.responseText);
- xhttp.onreadystatechange = xhttp.open = xhttp.send = null;
- xhttp = null;
- }
- }
- xhttp.open("post", "http://localhost:8888/g_dta.php", true);
- xhttp.send(request.data);
- });
Advertisement
Add Comment
Please, Sign In to add comment