Anbima Posted February 22, 2024 Posted February 22, 2024 Is it possible to integrate missing commands, such as key.split, via a self-created extension? I know that it works with Tampermonkey, but I would like to include it without additional extensions. If this is possible, what would have to be included in manifest.json and in, let's call it, function.js? 1
NotHereToPlayGames Posted February 22, 2024 Author Posted February 22, 2024 Where are you finding that "key.split" is even a command?
Anbima Posted February 23, 2024 Posted February 23, 2024 I have the following error in the console: Uncaught TypeError: key.split(...).at is not a function
NotHereToPlayGames Posted February 23, 2024 Author Posted February 23, 2024 Please provide an example web site.
Anbima Posted February 23, 2024 Posted February 23, 2024 3 hours ago, NotHereToPlayGames said: Please provide an example web site. https://storage.enganchesaragon.com/public-websites/ecommerce/pdf_viewer/web/viewer.html?file=https://storage.enganchesaragon.com/public-websites/ecommerce/Inst/C0801E.pdf 1
UCyborg Posted February 23, 2024 Posted February 23, 2024 This probably refers to Array.prototype.at(). 1
Anbima Posted February 23, 2024 Posted February 23, 2024 5 minutes ago, UCyborg said: This probably refers to Array.prototype.at(). Can this be fixed via a self-created extension? If so, what would have to be listed in the respective files?
UCyborg Posted February 24, 2024 Posted February 24, 2024 (edited) Maybe something like: manifest.json { "manifest_version": 2, "name": "Polyfillz", "version": "1", "description": "Monkey patch old Chrome to add new JavaScript functionalities.", "content_scripts": [ { "matches": [ "<all_urls>" ], "js": [ "content.js" ], "run_at": "document_start", "all_frames": true } ], "web_accessible_resources": [ "polyfills.js" ] } content.js 'use strict'; const script = document.createElement('script'); script.setAttribute('src', chrome.runtime.getURL('polyfills.js')); (document.head || document.documentElement).appendChild(script); script.remove(); polyfills.js 'use strict'; if (!Array.prototype.at) { Array.prototype.at = function(index) { if (index >= 0) { return this[index]; } else { return this[this.length + index]; } }; } Edited February 24, 2024 by UCyborg 1
Anbima Posted February 24, 2024 Posted February 24, 2024 14 hours ago, UCyborg said: Maybe something like: Unfortunately it does not work. Any other ideas?
NotHereToPlayGames Posted February 24, 2024 Author Posted February 24, 2024 4 hours ago, Anbima said: Unfortunately it does not work. Any other ideas? That's because that is only one half, one third, one fourth of the problem. Only after you resolve array.at does structuredclone error show up. Then after you resolve that, you're likely to encounter even more errors. You do not need an online viewer to view .pdf's - download it then drag and drop into 360Chrome, bypass that "viewer" -- https://storage.enganchesaragon.com/public-websites/ecommerce/Inst/C0801E.pdf 2
rereser Posted February 25, 2024 Posted February 25, 2024 (edited) here is a modified Array.at() polyfill to install in your userscript manager. ----------------------------------------------------------------------------- // ==UserScript== // @name Inject Array.at() Polyfill (92) // @version 0.0.1 // @match *://*/* // @run-at document-start // @grant none // ==/UserScript== function at(n) { // ToInteger() abstract op n = Math.trunc(n) || 0; // Allow negative indexing from the end if (n < 0) n += this.length; // OOB access is guaranteed to return undefined if (n < 0 || n >= this.length) return undefined; // Otherwise, this is just normal property access return this[n]; } const TypedArray = Reflect.getPrototypeOf(Int8Array); for (const C of [Array, String, TypedArray]) { Object.defineProperty(C.prototype, "at", { value: at, writable: true, enumerable: false, configurable: true }); } --------------------------------------------------------------------------------- the first one was posted before: https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/page/13/#comment-1245468 it passed the test at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at this modified version works with the mozilla test and the pdf site. (give it a few seconds to load) you will need more polyfills like structuredclone, and probably others, installed as NHTPG pointed out. source: https://stackoverflow.com/questions/68464114/why-am-i-getting-at-is-not-a-function other source: https://github.com/tc39/proposal-relative-indexing-method?tab=readme-ov-file#polyfill Edited February 25, 2024 by rereser 3
Anbima Posted February 25, 2024 Posted February 25, 2024 19 hours ago, NotHereToPlayGames said: You do not need an online viewer to view .pdf's - download it then drag and drop into 360Chrome, bypass that "viewer" -- https://storage.enganchesaragon.com/public-websites/ecommerce/Inst/C0801E.pdf That's how I've been doing it so far. But I thought it might be easy to get around this. Unfortunately, that's probably not the case.
NotHereToPlayGames Posted February 25, 2024 Author Posted February 25, 2024 On 2/22/2024 at 1:07 PM, Anbima said: I know that it works with Tampermonkey, but I would like to include it without additional extensions. 26 minutes ago, Anbima said: Unfortunately, that's probably not the case. You're not wanting to use Tampermonkey and polyfilling via Tampermonkey. Kind of not "our fault" when we give a method that WORKS but you don't want to use that method.
VistaLover Posted February 25, 2024 Posted February 25, 2024 18 minutes ago, Anbima said: 19 hours ago, NotHereToPlayGames said: You do not need an online viewer to view .pdf's - download it then drag and drop into 360Chrome, bypass that "viewer" -- https://storage.enganchesaragon.com/public-websites/ecommerce/Inst/C0801E.pdf That's how I've been doing it so far. But I thought it might be easy to get around this. One other approach I use myself is to let the browser handle itself the online PDF files (without a prior download to disk and then drag-n-drop ) and display them via its native PDF viewer; however, in the case discussed, https://storage.enganchesaragon.com/public-websites/ecommerce/Inst/C0801E.pdf the file has an "attachment" content-disposition and loading that URI will generate a "Save File" download prompt; that's why I have also installed: https://chromewebstore.google.com/detail/undisposition-racle-fork/bbppejejjfancffmhncgkhjdaikdgagc and I enable it as needed - you want the older v0.0.4, which is still at MV2, for 360EE... Below is KafanMiniBrowser loading the referenced PDF URI in its default viewer, via "undisposition" extension : 3
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now