在Google Chrome浏览器中,将Javascript插入网站的简单方法是什么? [英] What's a simple way in Google Chrome to insert Javascript into sites?

查看:70
本文介绍了在Google Chrome浏览器中,将Javascript插入网站的简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将javascript的自定义代码段添加到与正则表达式匹配的任何网站.这主要是因为我每天都会使用一些专门内容的网站,但是这些网站的设计较差.我希望能够做类似的事情:

I would like to be able to add custom snippets of javascript to any site that matches a regex. This is mostly because of sites that I use daily because of specialized content, but which have a poor design. I want to be able to do something like:

  • 访问网站,看到侧边栏会覆盖内容
  • 选择开发人员工具,查找侧边栏的div ID
  • 编辑在document.ready上为此域执行的javascript片段:

  • Visit site See that sidebar overwrites content
  • Whip out developer tools, find div id for sidebar
  • Edit a snippet of javascript which is executed on document.ready for this domain:

$('#sidebar-right').remove();

一些搜索用户脚本的过程告诉我,我需要编写一个Chrome扩展程序,这似乎是不幸的和过分的.有没有更简单的方法,或者是仅是将片段分配给域的javascript编辑器的扩展?我真的很希望能够在Chrome本身中进行编辑,或者至少拥有一个我可以一直在MacVim中保持打开状态的文件.据我所知,扩展需要卸载/安装才能更新.

A bit of searching for user scripts tells me that I need to be writing a Chrome extension, which seems unfortunate and overkill. Is there not an easier way, or an extension which is nothing but a javascript editor that assigns snippets to domains? I'd really like to be able to edit in Chrome itself, or at least have a file that I can just leave open in MacVim all the time. An extension requires unloading/installing to update as far as I can tell.

如果我只有一个大的javascript文件,那很好.我只是将自定义内容包装在域检查中.

If I just had one big javascript file, that would be fine. I'd just wrap my customizations in domain checks.

如果我能用CoffeeScript写作,那就加倍爱.

Bonus love if I can write in CoffeeScript.

推荐答案

答案是Tampermonkey.

The answer was Tampermonkey.

https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo

这篇关于在Google Chrome浏览器中,将Javascript插入网站的简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆