Answer the question
In order to leave comments, you need to log in
How to change the style of a page loaded by a post request using a Chrome extension?
Good day everyone! Help proofs and masters.
I'm writing an extension for Chrome
The extension should load (open) the page when you click on the button in the popup, change the style of the necessary elements and send the file for printing.
manifest.json;
{
"manifest_version": 2,
"name": "Extension",
"version": "1.0",
"description": "Easy app extension",
"browser_action": {
"default_title": "Extension",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
],
"content_scripts": [{
"matches": [ "http://mi.url.ru/*" ],
"js": ["popup.js", "jquery.js"]
}]
}
<!doctype html>
<html>
<head>
<title>Приложение</title>
<script src="popup.js"></script>
<script src="jquery.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body id='toby'>
<h3>Заголовок:</h3>
<button id="checkPage">start</button>
<div id="dannie"></div>
</body>
</html>
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('checkPage');
checkPageButton.addEventListener('click', function() {
chrome.tabs.getSelected(null, function(tab) {
d = document;
var f = d.createElement('form');
f.action = tab.url;
f.method = 'post';
var i = d.createElement('input');
i.type = 'hidden';
i.name = 'url';
i.value = tab.url;
f.appendChild(i);
d.body.appendChild(f);
f.submit();
//alert(i.value);
window.print(); //печать, после скрытия элементов
});
}, false);
}, false);
.ZS{display:none !important;font-size:0pt !important;}
.zS{display:none !important;font-size:0pt !important;}
strong{display:none !important;font-size:0pt !important;}
p{display:none !important;font-size:0pt !important;}
table{display:none !important;font-size:0pt !important;}
.xY{display:none !important;font-size:0pt !important;}
.wY{display:table-cell !important;}
h4{text-align:center !important;margin-top:5px !important;}
img{margin-bottom:30px !important;}
var el = document.getElementsByTagName("img");
this.style.cssText = 'display:none !important;';
и так:
this.setAttribute('src', '')
src="/show/utils/barcode?code=*"
Answer the question
In order to leave comments, you need to log in
1. What's wrong?
1.2 To manipulate the contents of a tab, you need to insert content scripts into it.
2. Actually, see paragraph 1.2.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question