Create a web browser link that opens a file in Intellij. Possible? - google-chrome

Example, qbittorent can be made to open links that are of torrent files.
Email clients mailto:
Is it possible to create links in a browser that will open the given file in Intellij? (Not full path, but entire package possibly ).
Idea is that this will be created for bitbucket.

There is an open feature request to add idea:// protocol handler.
At the moment it works on macOS only out of the box. For other platforms you can try the third-party solution or other workarounds from the ticket comments.
There is also a built-in web server providing the REST API to open files.
It will work with the relative paths only when the IDE is already running and the project is open: http://localhost:63342/api/file/relative/to/module/root/path/to/file.kt.
With the JetBrains Toolbox App installed one will be able to use jetbrains:// protocol for navigation, it's work in progress and should be available in 2019.2.
See JBProtocolNavigateCommand.kt for the reference:
// handles URLs of the following types:
// jetbrains://idea/navigate/reference?project=IDEA
// [&reference[X]=com.intellij.navigation.JBProtocolNavigateCommand[.perform][#perform]]+
// [&path[X]=com/intellij/openapi/project/impl/JBProtocolNavigateCommand.kt[:23[:1]]]+
// [&selection[X]=25:5-26:6]+
Sample URL:
jetbrains://idea/navigate/reference?project=IDEA&fqn=com.intellij.openapi.application.JetBrainsProtocolHandler#getParameters
Toolbox URL matches regexp:
"${JetBrainsProtocolHandler.PROTOCOL}([\\w\\-]+)/navigate/reference\\?project=(?<project>[\\w]+)(&fqn[\\d]*=(?<fqn>[\\w.\\-#]+))*(&path[\\d]*=(?<path>[\\w-_/\\\\.]+)(:(?<location1>[\\d]+))?(:(?<location2>[\\d]+))?)*(&selection[\\d]*=(?<line1>[\\d]+):(?<column1>[\\d]+)-(?<line2>[\\d]+):(?<column2>[\\d]+))*"
There will be also UI for copying TBX protocol URLs directly from the editor similar to the Copy Reference action in the context menu. The same will work for IDE settings navigation.

As an update to #CrazyCoder's answer
This works* on Mac currently. (unable to test on anything else personally)
* There are some issues:
There is no context menu option for generating this link from clicking on a line of code
The keybinding (see below) generates the incorrect path, and it needs to be modified manually by either changing the sources root temporarily, or typing the missing path parts by hand.
There is a keybinding you can use to generate the url, under Preferences > Keymap > Copy Path/Reference > Toolbox URL. Note that the cursor location when using the keybinding matters. From what I can tell, if the cursor is at the beginning or end of a line, it generates a url with &path=..., else it generates with &fqn=.... The fqn option will often link to the wrong area of the code, especially when interfaces, libraries, auto-wiring, or anything not a direct vanilla class/object/function is attempted to link to.
I have filed an issue with more details on the broken path generated by the keybinding: https://youtrack.jetbrains.com/issue/IDEA-290640

Related

browser debugger - how to change script code [duplicate]

Is it possible to modify the JavaScript of a page and then reload the page without reloading the modified JavaScript file (and thus losing modifications)?
This is a bit of a work around, but one way you can achieve this is by adding a breakpoint at the start of the javascript file or block you want to manipulate.
Then when you reload, the debugger will pause on that breakpoint, and you can make any changes you want to the source, save the file and then run the debugger through the modified code.
But as everyone has said, next reload the changes will be gone - at least it lets you run some slightly modified JS client side.
Great news, the fix is coming in March 2018, see this link: https://developers.google.com/web/updates/2018/01/devtools
"Local Overrides let you make changes in DevTools, and keep those changes across page loads. Previously, any changes that you made in DevTools would be lost when you reloaded the page. Local Overrides work for most file types
How it works:
You specify a directory where DevTools should save changes. When you
make changes in DevTools, DevTools saves a copy of the modified file
to your directory.
When you reload the page, DevTools serves the
local, modified file, rather than the network resource.
To set up Local Overrides:
Open the Sources panel.
Open the Overrides tab.
Click Setup Overrides.
Select which directory you want to save your changes to.
At the top of your viewport, click Allow to give DevTools read and write access to the directory.
Make your changes."
UPDATE (March 19, 2018): It's live, detailed explanations here: https://developers.google.com/web/updates/2018/01/devtools#overrides
The Resource Override extension allows you to do exactly that:
create a file rule for the url you want to replace
edit the js/css/etc in the extension
reload as often as you want :)
In the devtools preferences check the Enable local overrides.
Go to network tab, find the file you want to edit, rigth click on it and select Save for overrides (on the sources/overrides tab you need to add a local folder)
The file appears in a new tab on the Sources tab as local copy, so you can edit this file, and after site reload the new (and edited) override file will load on the site!
I know it's not the asnwer to the precise question (Chrome Developer Tools) but I'm using this workaround with success: http://www.telerik.com/fiddler
(pretty sure some of the web devs already know about this tool)
Save the file locally
Edit as required
Profit!
Full docs: http://docs.telerik.com/fiddler/KnowledgeBase/AutoResponder
PS. I would rather have it implemented in Chrome as a flag preserve after reload, cannot do this now, forums and discussion groups blocked on corporate network :)
Yes you can eazily!
Source -> filesystem -> choose the conatainer folder -> allow access -> open your file, edit and save.
https://www.delftstack.com/howto/javascript/edit-javascript-in-the-browser/

Invoke or use Chrome Object from javascript

I'm trying to customize my own chrome://inspect/#devices , I see it uses utils.js and inspect.js and at the same time it uses a global "chrome" object in the original ones, how do I invoke it from my own inspect.js? Right know I just have a local clone:
Clone folder of chrome://inspect/#devices
devices.html
inspect.js
util.js
jquery.js
So I load devices.html but is not working, and the first obstacle I have is that global object "chrome" is not available for inspect.js.
I found a somehow related thread Can `chrome.*` extension API's be used inside content scripts?
chrome://inspect is one of the build-in Chrome pages (all are listed here - chrome://about/). These pages are considered an integral part of the browser and they have access to special actions (via chrome object). Browser will not inject chrome object into the regular pages (such as your copy of the inspect page).
Unfortunately, you won't be able to modify chrome://inspect page (even with an extension as you can't inject scripts into chrome:// pages). However, you might be able to recreate that page in an extension using debugger API.

Change to this file were not saved to file system error in google chrome version 30.0.1599.101 m

In the google chrome version 30.0.1599.101 m I am not able to save the changed js file.
On saving the js file I got yellow triangle symbol with "change to this file were not saved to file system" message.
I know this used to work in older version
I am using windows-7 64 bit
Click on the cog in the developer tools window (lower right corner)
Go to workspace and add the directory which you would be working on.
This is to accidentally prevent you from modifying files that you did not intend on changing.
Happened to me too. After picking the workspace directory, I also mapped the file from the "Source" panel of Devtools to its filesystem equivalent (using right-click on the file, from the file tree). It solved my problem.
In chrome > 63, accepted answer option is disabled.
In later should be done through workspaces.
Tonight, I accidentally managed to fix this problem, just open the file on the disk and save it with a simple change even with a space.
Refresh the page in Chrome, Chrome will link it(The file) to the disk.
Using Ctrl + F5 to clear the browser cache worked for me.
I found nothing in "workspace" that seemed relevant, and other things people listed didn't help either. What helped was to go in dev tools, where it says Pages, Sources etc., there is also Overrides (duh :)), I chose it, it said "Select folder for overrides", I did, and then also clicked "Allow" on Chrome asking for confirmation. That's it, after that I was able to save the files, the overrides worked.
Ok, my case might be a bit different but I will share my experience on what I was facing that caused to this warning and how I solved it.
I was trying to check a certain strange behavior on a React app for video streaming, so I opened up Developer console, enabled local overrides and tried editing the js file, immediately upon saving I got the warning “Changes to this file were not saved to file system”.
Note the message at bottom right “Source mapped from app.bundle.min.js”, this indicated that this is not an actual file but a mapping from the app.bundle.js (Webpack bundle)
So I moved to editing the app.bundle.min.js, I searched the appropriate string I was interested in from the mapped file (react-dom.production.min.js) and searched it in app.bundle.min.js
Again I got the same warning but I noticed the “app.bundle.min.js” file was fetched using a url parameter ?v=4900, I decided to remove it to check if that was the culprit causing the issue, to achieve that I modified the index.html file and edited the script tag that was fetching the js file from
<script src="libs/app.bundle.min.js?v=4900"></script> to <script src="libs/app.bundle.min.js"></script>
After that I forced refresh the page (Shift+F5, normal refresh didn’t work), tried modifying and saving and Jackpooot!! (Take away: You can’t override files fetched with a url parameter). I then was able to beautify, modify and override the app.bundle.min.js implementation and achieved what I wanted.
On Chrome Version 109~ :
Go to F12 > Sources Tab > Overrides (You may need to click the chevron next to Page)
Select/Create a folder to contain Overrides
You can now right-click a file or editor window & save it for Overrides
Image of sources tab where Overrides is located
Something to note: if you are making dynamically loaded JS available in devtools via the helpful: //# sourceURL=Example.js comment, this network to local mapping will not work.
Note: Notice the "//# sourceURL=dynamicScript.js" line at the end of dynamicScript.js file. This technique gives a name to a script created with eval, and will be discussed in more detail in the Source Maps section. Breakpoints can be set in dynamic JavaScript only if it has a user supplied name.
https://developer.chrome.com/devtools/docs/javascript-debugging
When you're using sourceURL, you can't actually find the respective JS file in the Sources tree where you might expect it to exist. It is available to open via the "no-domain" tree, however (or quick open with CTRL/CMD+P).
I'm still looking for a solution.
The easiest solution I found to this problem:
(keep in mind, I was manipulating an html page that lives on my machine)
open the associated html page from the command line so the page displays
for mac, that's simply $ open <name>.html
open Dev Tools
open Sources tab
in Page, open a new .js file there with whatever name you need
write in some text and save
This worked for me. Yes, I had to create a new .js file, but my directory locally recognized it was there when I pulled it, and my editor was updating in real time with the dev tools each time I saved either. At that point, my editor and the dev tools source tab had become one thing.
Currently on Chrome 100.0.4896.60 (Official Build) (x86_64).
I've got a js file with source maps; the override has always been spotted.
I'm able to override the map file (which won't work though for the debugging purpose) and the index.html file.
Apparently my issue is related to minified js with source maps.
Seem to work in relation to the chrome version installed.
I tried the following attempts but didn't work:
remove cache
disable / enable override
add the dir to the workspace
install chrome canary
To debug then I've tried:
build my file.min.js to test. In my case was production/file.min.js
start a npx http-server in production (cd production && npx http-server) which open to http://127.0.0.1
override index.html to consume http://127.0.0.1/file.min.js
Interesting considerations:
When i was doing basic overriding i had to replace the file manually all the times.
Now, I've got a watch task going on and i can basically refresh the page.
I can see as well the source map update.
It's simple! Right click on your page, Go to Inspect, go to the Network tab and tick the check box 'Disable cache'. Reload the page and you will see the effect.

Chrome Workspaces - Saves changes in Sources tab but not Elements

I'm trying to setup and use Workspaces on Canary and I'm running into a few issues.
I understand that is still under development but could someone clarify these issues i'm having aren't or are related to the fact that its still under development?
Basically I setup a workspace in DevTools, locating the directory on my file system. Do I need to put anything in URL prefix and folder path input boxes? I've experimented leaving them blank, filling them in etc, but due to the lack of documentation I'm not sure what the correct input is.
Most of the time I run my sites through MAMP so will custom server names alter the configuration?
When I then open open the page I am editing, open the dev tools, make changes in the elements styles sidebar, it doesn't save any changes to the file on my system. But then when I go into the Sources tab and locate the workspace from the slide-out menu on the left, I can make changes to the files directly there. But I have to refresh the browser to see any changes.
I know something isn't quite right because when I watched Paul Irish's little demo a while back, he was making changes in the elements styles bar and seeing the results without refresh and changes being saved automatically. How can I get that this point?
Thanks in advance.
PS. If someone could add chrome-canary and chrome-workspaces tags, that would be great.
Once you have added a local filesystem, right-click a local file in your Sources panel and choose "Map to Network Resource", then select the network resource it corresponds to. That should set up the right mapping automatically.
URL prefix and folder path should correspond to the root of your app (the root url, on the server) and the root folder of your app in the file-system respectively. Alexander Pavlov is correct - if you set the network mapping for an individual file, and restart Dev Tools, these mappings will be made for the entire map, automatically as Dev tools makes the connections. In other words, do it for one file and you may not have to fill in those fields for the workspace yourself, Dev tools will do it automatically. Very handy.

Handling 'choose a digital certificate' with selenium webdriver chrome

When I open a page with selenium webdriver I get a chrome dialog box "Choose certificate". The default certificate is the right one so I only have to click OK button. But I have problem with this. I have python code:
drv = webdriver.Chrome()
drv.get("https://example.com/login")
and after that I want to do something like:
drv.switch_to_alert().accept()
or
drv.switch_to_alert().send_keys(Keys.TAB)
drv.switch_to_alert().send_keys(Keys.SPACE)
The problem is that the code stops executing on line drv.get("https://example.com/login"). Webdriver is waiting for page to load. And before that line there is no chrome dialog box.
How can I handle this?
You'll have to use something like AutoIT:
http://www.autoitscript.com/site/autoit/
Why you ask? It's an OS dialog, which Selenium does not and probably never will handle, so you'll have to turn to other solutions (in C# you should use native Win32 API methods to click the button for instance).
Certificates are managed by the OS, not the browser. Delete all but the necessary certificate from your browser's certificate store and then configure the browser to automatically select the certificate when only one certificate is present. You could also create a browser profile and have your program launch this profile or avoid testing over HTTPS.
before handling anything here, add below so it will not get frozen as soon as you navigate/triggert the certificate pop up. remeber to add the correct waittime back later.
getDriver().manage().timeouts().pageLoadTimeout(1000, TimeUnit.MILLISECONDS);
after this, then you can try using keyboard or autoIt whatever .
You can configure you Policys Group for Chrome choose your certificate.
Chrome use a registry with a json with information of your certificate. After you configure gpo,find a way to modified this json with Python.
With C# I use Microsoft.Win32.Registry to manipulates the registrys.
Follow the steps to configure you gpo:
First I need to thanks IngussNeilands for the tutorial provided on his Github. It saved me!
You can follow the steps on IngussNeilands´s tutorial here or follow my version of his tutorial below.
## Steps to Configure the Policy Groups
Download Chrome Policy Tamplates from here: http://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip
Extract the .zip file and find the chrome.adm that matches the country and the language settings on your Windows, following the path: policy_templates\windows\adm\<YourCountryAndLanguage>\chrome.adm
Type "run" into your Windows Search Bar or press Windows + R. Then type de command gpedit.msc to open the The Local Group Policy Editor
Now, access: 'Computer Policy>> Computer Configuration' and right-click the file 'Administrative Templates' and select 'Add or remove tamplates'
Click 'add' and navigate to the chrome.adm that you choose before on 'policy_templates\windows\adm\<YourCountryAndLanguage>\chrome.adm'. Click to open it
Now, navigate to:
'Computer Policy>> Computer Configuration>> Administrative Templates>> Classic Administrative Templates(ADM)>> Google>> Google Chrome>> Content Settings'
Then on the rigth side of the window find and double-click the option 'Automatically select client certificates for these sites'
Click the 'Enabled' option
Now, Click the 'Show...' in the option pane below
Copy and paste the 'JSON' below in the line of the column Value:
{"pattern":"https://[*.]example.com","filter":{"ISSUER":{"CN":"example.com"}, "SUBJECT":{"CN":"value"}}. This JSON needs to be rewriten with your certificate informations
How to rewrite the Chrome Configure JSON
Ok, now a will give you a brief explanation on how to rewrite the Chrome Config JSON.
In the "pattern" key the value needs to be the URL that the certificate will be sent to. In most cases this URL is the same URL of the page, but some sites don´t use the same URL base to send the certificate.
For example, when I was trying to webscraping the NFS-e in Uberlândia city I needed to debug the script of the page to find the URL to where the certificate was sent.
The "filter" key will have the certificate information. In my case, I need to access the same website with diferent certificates, for that I'll have to fill the JSON with the information of "ISSUER" and "SUBJECT". Chrome will choose one certificate that matches with the informations content in the filter key. For example, if I fill the "CN" from "ISSUER" object with "SERASA Certificadora Digital v5" I'll have more than one certificate with these informations and Chrome won´t be able to choose the right certificate.
In my git in here you can find the solution to alter the JSON for access the same site with more the one certificate.