Is CSS injection possible on iPad using Safari?
There is a possibility to use a custom style sheet in Safari on Mac to inject CSS syntax that changes the rendered output of web pages.
I’m seeking a similar tool for iPad and iPadOS.
Is there any way to use CSS injection in Safari or other browsers on the iPad?
Solution 1:
To inject a custom CSS into a webpage on iPad you can use the app Shortcuts. First, you need to create a new shortcut:
Open Shortcuts
Select Create Shortcut > Web > Run JavaScript on Web Page
Use the following JavaScript:
function addStyleString(str) {
var node = document.createElement('style');
node.innerHTML = str;
document.body.appendChild(node);
}
addStyleString('body { color: red !important }');
addStyleString('body { background: silver !important }');
// This way allows you to add CSS in multiple passes
// Call completion to finish
completion();
Tap Next
Add the Shortcut Name
To apply a custom CSS you need to run the shortcut in Safari:
Open a web page in Safari
Tap on the share button
Scroll all the way down and tap on the newly created shortcut.
HINT: Use !important
in CSS injections to override default rules.