Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
Please add support for
inegrity
(SRI). See also Subresource Integrity issue.I'm attempting to add
integrity
attribute to a style I use for userscript Newspaper (ATOM/RDF/RSS)Test page: https://mastodon.tedomum.net/@tedomum.rss
The error is this:
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' https://mastodon.tedomum.net 'nonce-FF4fvS9IB+e83sIyujPoyw=='". Either the 'unsafe-inline' keyword, a hash ('sha256-JjOHpf1r2ZHN4jxJdiFIgopy2yA5l3DibXaFr1c70F4='), or a nonce ('nonce-...') is required to enable inline execution.
I used the output of these commands: (also used
sha256
)cat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -A
shasum -b -a 384 FILENAME.js | awk '{ print $1 }' | xxd -r -p | base64
This is the part where integrity is applied:
if (isRTL) { stylesheet .textContent = stylesheet_ltr + stylesheet_rtl; stylesheet .setAttribute( 'integrity', 'I NEED HELP IN GETTING STRING CHECKSUM' ); } else { stylesheet .textContent = stylesheet_ltr; stylesheet .setAttribute( 'integrity', 'I NEED HELP IN GETTING STRING CHECKSUM' ); }
Please delete first post and this post
I'm attempting to add
integrity
attribute to a style I use for userscript Newspaper (ATOM/RDF/RSS)Test page: https://mastodon.tedomum.net/@tedomum.rss
The error is this:
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' https://mastodon.tedomum.net 'nonce-FF4fvS9IB+e83sIyujPoyw=='". Either the 'unsafe-inline' keyword, a hash ('sha256-JjOHpf1r2ZHN4jxJdiFIgopy2yA5l3DibXaFr1c70F4='), or a nonce ('nonce-...') is required to enable inline execution.
I used the output of these commands: (also used
sha256
)cat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -A
shasum -b -a 384 FILENAME.js | awk '{ print $1 }' | xxd -r -p | base64 ``` This is the part where integrity is applied: ```js if (isRTL) { stylesheet .textContent = stylesheet_ltr + stylesheet_rtl; stylesheet .setAttribute( 'integrity', 'I NEED HELP IN GETTING STRING CHECKSUM' ); } else { stylesheet .textContent = stylesheet_ltr; stylesheet .setAttribute( 'integrity', 'I NEED HELP IN GETTING STRING CHECKSUM' ); }
Thank for the help, by the way ;)
Hello,
I've made a Userscript inspired by a Userscript by @raingart.
I need help with MutationObserver.
This is the Userscript
Please don't write the name of the website, the brand name starts with
A
and ends withN
.Kindly,
Schimon
This is my attempt to apply your solution on another website:
//regex = '/^\s*\n/gm' // .replace(regex, ''); function sumUp() { //sumUp = (function sumUp(){ //sumUp = (function(){ // Uncaught TypeError: sumUp is not a function let tag, fee, sum; const // /questions/1183903/regex-using-javascript-to-return-just-numbers regex = /[-]{0,1}[\d]*[.]{0,1}[\d]+/g, prices = [], selectors = [ '.a-price-whole', '.a-price-fraction', '.a-size-base.a-color-secondary', ], priceConfig = { minimumFractionDigits: 2, maximumFractionDigits: 2 }; for (let i = 0; i < selectors.length; i++) { try { prices[i] = document .querySelector(selectors[i]) .textContent .trim(); } catch { console.log(`No ${selectors[i]}`); } } tag = prices[0] + prices[1]; tag = tag.match(regex).join(''); tag = parseFloat(tag); fee = parseFloat(prices[2].match(regex).join('')); sum = tag + fee // Method .toFixed(2) might be preferable. See raingart. sum = sum.toLocaleString(navigator.language, priceConfig); priceSum = document.createElement('span'); priceSum.style.fontWeight = 'bold'; priceSum.style.padding = '6px'; priceSum.style.margin = '20px'; priceSum.style.outline = 'auto'; priceSum.innerHTML = `∑${sum}`; document.querySelector('.priceToPay > span:nth-child(2)').append(priceSum); //for (const val of document.querySelectorAll('.a-price-whole')) { // val.innerHTML = `${sum}<b>∑</b><sup><sup>(<sup>$</sup>${tag} + <sup>$</sup>${fee})</sup></sup>`; //} //})(); } sumUp() /* // define the target node var targetNode = document.querySelector('.a-price-whole'); // configuration of the observer const config = { childList: false, characterData: true, subtree: true, attributes: false, }; // callback function const callback = function (mutationsList, observer) { console.log('Changes Detected'); if (!targetNode.outerText.includes(' + ')) { sumUp(); } }; // Create observer instance const observer = new MutationObserver(callback); // pass in the target node and configuration observer.observe(targetNode, config); observer.observe(targetNode, config); */ const observerConfig = { childList: false, characterData: true, subtree: true, attributes: false, }; new window.MutationObserver(sumUp).observe(document.querySelector('.a-price-whole'), observerConfig);
Please document your script.
I want to learn
MutationObserver
, yet all of the documentations I've read thus far are either not clear or over complicated.Your script seems to be a good example for people who are new to
MutationObserver
.outline: "auto", padding: "3px",
Yes, it is possible to use
@require
for this https://openuserjs.org/libs/Anakunda/langCodesIt is also possible download a file with GM.xmlHttpRequest, but I'm not sure it is possible to store it.
Solved.
This library has been tested with userscript managers; it seems to be an issue with Falkon https://bugs.kde.org/show_bug.cgi?id=468066
@admins Please change title to "Standard alternatives to GM.getValue/GM.setValue".
Thank you
This script works and uses
localStorage
.Is it wise to use
localStorage
overGM.getValue
/GM.setValue
?I guess a given website can read the
localStorage
value set by a userscript.Can websites read values of
GM.getValue
?Because GM.getValue/GM.setValue don't seem to work uniformly with all userscript mangaers, I'm attempting to utilize "web-messaging", for storing values, as a general replacement to GM.getValue/GM.setValue.
This is my most recent attempt: https://openuserjs.org/scripts/sjehuda/Dimmer_(web-messaging)
The problem is that upon reload, the value is erased, thus
window.addEventListener('message', receiver);
returnsundefined
.Thank you, Marti!
Please add description to the library and it's functions.
Hello,
I've uploaded a library and I've failed to get it to work with this userscript.
I've already managed to use a library before, with this userscript.
Please advise,
Schimon
Hello,
I've decided to rebrand FREEdirector to Proxy Redirect.
Is there an automated manner to do so?
Currently, I've changed the older program to direct users to it's project page, in the hope they will see the message and install the new one, but it doesn't seem to work as the installation amount of the older programs keeps growing.
Please advise,
Schimon
According to jesus2099, the program Kiwi Browser has userscript support.
This is clearly an attempt to sabotage web feeds, as this article suggests.
To prove my claim, copy and paste one of these scripts to Console and execute.
https://openuserjs.org/scripts/sjehuda/Newspaper
https://openuserjs.org/scripts/sjehuda/Newspaper_(XMLHttpRequest)
Falkon, Otter, Qutebrowser etc. WILL render the XML file into an HTML.
Firefox, however, will produce the following error:
// ==UserScript== // @name Newspaper (XMLHttpRequest) // @namespace io.github.sjehuda.syndication4human // @description Native Feed Viewer. Render syndication web feeds (supports Atom, RDF and RSS) // @homepageURL https://sjehuda.github.io/newspaper.html… undefined Uncaught Exception { name: "", message: "", result: 2153775105, filename: "debugger eval code", lineNumber: 210, columnNumber: 0, data: null, stack: "renderFeed@debugger eval code:210:4\ncheckMediaType@debugger eval code:157:13\nhttpGetAsync/xmlHTTPRequest.onreadystatechange@debugger eval code:97:15\nEventHandlerNonNull*httpGetAsync@debugger eval code:77:3\n@debugger eval code:57:13\n" } debugger eval code:210 renderFeed debugger eval code:210 checkMediaType debugger eval code:157 onreadystatechange debugger eval code:97 (Async: EventHandlerNonNull) httpGetAsync debugger eval code:77 <anonymous> debugger eval code:57 getEvalResult resource://devtools/server/actors/webconsole/eval-with-debugger.js:251 evalWithDebugger resource://devtools/server/actors/webconsole/eval-with-debugger.js:172 evaluateJS resource://devtools/server/actors/webconsole.js:974 evaluateJSAsync resource://devtools/server/actors/webconsole.js:865 makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103
A specific mistake of such is very likely intentional, not accidental.
Of note: When I began with XSLT and Javascript (i.e. XSLTProcessor) the MDM documentations were the worst of all others I've found, as if it is intentional by MDM to make people reluctant to XSLT and eventually its great usefulness.
Mozilla officers are welcome to provide an explanation to the above.
Kindly,
Schimon
I need help making image loading better.
Concerning to userscript Newspaper.
Since document is processed while is "on load" (aka "on the fly"), I want to replace all attributes of
src
tosrc-data
while program processes the document.I've attempted to do so by adding to function
renderFeed
the following code which doesn't work for all images, or is it? (I might need to check again)for (const image of newDocument.querySelectorAll('img')) { //source = image.src; //image.removeAttribute('src'); //image.setAttribute('src-data', source); image.setAttribute('src-data', image.src); image.removeAttribute('src'); }
Yet, below the execution of code
document.replaceChild(insertDocument,removeDocument);
I've added this code:for (const image of document.querySelectorAll('img')) { image.addEventListener('mouseover', loadImage(image)) image.onmouseover = () => { image.removeEventListener('mouseover',loadImage(image)) } }
Which causes the infinite loop if the line of function
loadImage
is not commented out.function loadImage(image) { console.log('onmouseover') source = image.getAttribute('src-data'); image.removeAttribute('src-data'); image.src = source; //image.removeEventListener('mouseover',loadImage(image)) // This line causes infinite loop. }
Note that I use
mouseover
event so it would be easier to test, though I want the event to trigger when animage
element is inside or close to viewport.P.S.
"Provident Image Load" (PIL) is a better name, eh?
Much better than the stupid phrase "Lazy (so called) Load".
Solved!
New code at
https://openuserjs.org/scripts/sjehuda/Newspaper
Old code at
https://openuserjs.org/scripts/sjehuda/Newspaper_(XMLHttpRequest)
Works! Done.
Reference: https://otter-browser.org/feed/
Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
GET https://otter-browser.org/feed/ net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) (anonymous) @ VM43 Newspaper:169 (anonymous) @ VM43 Newspaper:156 (anonymous) @ VM43 Newspaper:429
Of course not, the program never gets to
if (document.protocol == 'file:') { alert(document.protocol) mimeType = document.contentType; } else { mimeType = request .getResponseHeader('Content-Type'); }