LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-09-2022, 11:42 PM   #1
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,334
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
Shell script for browser extensions?


I have a one-liner shell script I'd like to apply from time to time to various web pages with the least amount of effort. It uses xmlstarlet but I could easily convert it to XSLT instead.

How would it be possible to turn that into a plug-in or extension for Firefox or Chromium? Must javascript always be involved or can I use plain shell scripting instead? There is a lot of material out there but what I have found so far is many years out of date.
 
Old 01-10-2022, 12:47 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
do you want to preprocess the page before displaying it or do you want to collect and save locally some info based on an url?
 
Old 01-10-2022, 01:04 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,334

Original Poster
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
Either is fine, whatever is the least work to run an XPath over the document before I get around to reading it.
 
Old 01-10-2022, 08:02 AM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555

I tried to do something similar last year, but I don't think it's possible to escape the JavaScript sandbox via Extension, and it wasn't worth the effort to pursue figuring out if/how Plugins could do it - but if you do figure it out I'd be interested to know.

 
Old 01-10-2022, 12:00 PM   #5
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
For browser extensions, Javascript is the only option. Actually there's also WASM, but compiling a shell script to WASM? It's maybe possible - but very complicated, and you will still need Javascript for the actual extensions. Also, WASM cannot access files, links or anything - it's sandboxed for a reason.

Every browser (and Javascript) has a good XML parser with xpath support. So it shouldn't be very hard to port it.

https://developer.mozilla.org/en-US/..._in_JavaScript

I would start with a super simple example extension from here:

https://developer.mozilla.org/en-US/...sions/Examples

For example borderify. Then do some xpath magic - either with the DOM or an external xml source. It can be done with very few lines of code. And if you get stuck, post the code in the programming forum.

Good luck.
 
1 members found this post helpful.
Old 01-11-2022, 03:15 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,334

Original Poster
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
Thanks. The link about XPath in javascript will be very useful once I brush up on the language.

However, the borderify script injects javascript into the page. For various reasons outside my influence, I cannot turn on javascript for the specific site to be processed. Maybe there is another example which adjusts the HTML itself without injecting javascript?
 
Old 01-11-2022, 03:34 AM   #7
lvm_
Member
 
Registered: Jul 2020
Posts: 961

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Check Greasemonkey https://addons.mozilla.org/en-US/fir.../greasemonkey/
 
Old 01-12-2022, 01:46 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
The "Open With..." addon allows you to run any executable against any link/page.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ISO 9660 Extensions: Microsoft Joliet Level 3, Extensions: RRIP_1991A postcd Linux - General 1 12-20-2021 07:04 AM
find all extensions than make directories of extensions using find command? finalturismo Linux - Software 23 09-25-2020 12:44 AM
eth0 no wireless extensions. and lo no wireless extensions rajeevnanu Linux - Laptop and Netbook 3 01-13-2020 03:33 PM
[SOLVED] Are web browser script blocker extensions necessary when running Linux? lake_wrangler Linux - Security 5 05-19-2015 09:57 AM
LXer: Gnome-Shell 3.2: Usable--but only with Gnome 2 shell extensions LXer Syndicated Linux News 0 05-13-2012 08:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration