Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dcbf0f

Browse files
author
minjk-bl
committed
Change file structure to integrate as 2.13 version for all extensions
1 parent124541a commit0dcbf0f

File tree

447 files changed

+21960
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

447 files changed

+21960
-1
lines changed

‎colab/background.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//======================================================================
2+
// Event for extension icon - toggle
3+
//======================================================================
4+
chrome.action.onClicked.addListener((tab)=>{
5+
// check origin if its url is matching our rule
6+
letcheckOrigin=tab.url.startsWith('https://colab.research.google.com/');
7+
if(checkOrigin){
8+
console.log('send toggle',checkOrigin,tab.id,tab);
9+
// send toggle action to content
10+
chrome.tabs.sendMessage(tab.id,"toggle").then(function(result){
11+
// success
12+
console.log('ok',result);
13+
}).catch(function(result){
14+
// error: if no content script, execute script again
15+
console.log('error',result);
16+
// execute script manually
17+
chrome.scripting.executeScript({
18+
target:{tabId:tab.id},
19+
files:['content.js']
20+
}).then(function(result){
21+
// toggle again
22+
chrome.tabs.sendMessage(tab.id,"toggle");
23+
});
24+
});
25+
}else{
26+
console.log("it's not colab site...");
27+
}
28+
});
29+
30+
// End of file

‎colab/content.js‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//======================================================================
2+
// Inner functions
3+
//======================================================================
4+
/**
5+
* Send event to inject script
6+
*@param {*} type event type defined on inject script
7+
*@param {*} data data to send
8+
*/
9+
functionsendEvent(type,data=''){
10+
letdetailObj={type:type,data:data};
11+
letevt=newCustomEvent('vpcomm',{bubbles:true,detail:detailObj});
12+
console.log('[vp content] send from content - ',type,data,evt);
13+
document.dispatchEvent(evt);
14+
15+
}
16+
functioncheckScriptExists(url){
17+
returndocument.querySelectorAll(`script[src="${url}"]`).length>0;
18+
}
19+
/**
20+
* Inject file
21+
*/
22+
functioninjectFile(){
23+
leturl=chrome.runtime.getURL('inject.js');
24+
console.log('[vp content] check inject file...')
25+
if(checkScriptExists(url)){
26+
console.log('[vp content] inject file already exist!');
27+
returnfalse;
28+
}
29+
console.log('[vp content] inject file!');
30+
// inject script
31+
vars=document.createElement('script');
32+
s.src=url;
33+
s.onload=function(){
34+
// send event to inject.js to send its url
35+
varurl=chrome.runtime.getURL('');
36+
// var evt = new CustomEvent('vpcomm', { bubbles: true, detail: { type: 'sendBase', data: url }});
37+
// document.dispatchEvent(evt);
38+
sendEvent('sendBase',url);
39+
};
40+
(document.head||document.documentElement).appendChild(s);
41+
returntrue;
42+
}
43+
44+
//======================================================================
45+
// Event listener - background <-> inject
46+
//======================================================================
47+
functionmsgHandler(msg,sender){
48+
if(msg=="toggle"){
49+
// var evt = new CustomEvent('vpcomm', { bubbles: true, detail: { type: 'toggle' }});
50+
// document.dispatchEvent(evt);
51+
// check if injected
52+
injectFile();
53+
sendEvent('toggle');
54+
}
55+
}
56+
chrome.runtime.onMessage.removeListener(msgHandler);
57+
chrome.runtime.onMessage.addListener(msgHandler);
58+
59+
console.log('[vp content] content script executed!');
60+
61+
// End of file
File renamed without changes.

‎colab/inject.js‎

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//======================================================================
2+
// Define variables
3+
//======================================================================
4+
window.vpBase=window.vpBase?window.vpBase:'';
5+
6+
//======================================================================
7+
// Define functions
8+
//======================================================================
9+
functionvp_log(msg){
10+
console.log('[vp] ', ...arguments);
11+
}
12+
functionvp_init(){
13+
// require config
14+
vp_config_require();
15+
}
16+
17+
functionvp_inject(path){
18+
vars=document.createElement('script');
19+
s.src=path;
20+
(document.head||document.documentElement).appendChild(s);
21+
s.remove();
22+
}
23+
24+
functionvp_config_require(){
25+
// Configure requirejs
26+
try{
27+
if(require===undefined||require==null){
28+
// remove inject script
29+
letinjectedScript=document.querySelector(`script[src="${vpBase}inject.js"]`);
30+
if(injectedScript){
31+
injectedScript.remove();
32+
}
33+
return;
34+
}
35+
}catch(ex){
36+
// remove inject script
37+
letinjectedScript=document.querySelector(`script[src="${vpBase}inject.js"]`);
38+
if(injectedScript){
39+
injectedScript.remove();
40+
}
41+
return;
42+
}
43+
require.config({
44+
baseUrl:vpBase,
45+
paths:{
46+
'vp_base' :'visualpython',
47+
'text' :'visualpython/lib/require/text',
48+
'css' :'visualpython/lib/require/css.min',
49+
'jquery' :'visualpython/lib/jquery/jquery-3.6.0.min',
50+
'jquery-ui' :'visualpython/lib/jquery/jquery-ui.min',
51+
'codemirror':'visualpython/lib/codemirror',
52+
'marked' :'visualpython/lib/marked/marked',
53+
'mathjaxutils' :'visualpython/lib/mathjax/mathjaxutils',
54+
'fontawesome' :'visualpython/lib/fontawesome/fontawesome.min'
55+
},
56+
shim:{
57+
"jquery-ui":{
58+
exports:"$",
59+
deps:['jquery']
60+
}
61+
},
62+
config:{
63+
text:{
64+
// allow CORS
65+
useXhr:function(url,protocol,hostname,port){
66+
// console.log('allow xhr');
67+
returntrue;
68+
},
69+
onXhr:function(xhr,url){
70+
// console.log(xhr);
71+
}
72+
}
73+
},
74+
map:{
75+
'*':{
76+
css :'visualpython/lib/require/css.min'
77+
}
78+
},
79+
packages:[{
80+
name:"codemirror",
81+
location:"visualpython/lib/codemirror/",
82+
main:"lib/codemirror"
83+
}]
84+
});
85+
86+
// Load vp
87+
define('vp/injectScript',[
88+
'text',
89+
'css',
90+
'jquery',
91+
'jquery-ui',
92+
'css!vp_base/lib/jquery/jquery-ui.min',
93+
'codemirror/lib/codemirror',
94+
'css!codemirror/lib/codemirror',
95+
'vp_base/js/loadVisualpython'
96+
],function(text,css,$,ui,uiCss,codemirror,cmCss,loadVisualpython){
97+
// codemirror
98+
window.codemirror=codemirror;
99+
100+
loadVisualpython.initVisualpython();
101+
});
102+
103+
}
104+
105+
//======================================================================
106+
// Event listener
107+
//======================================================================
108+
var_vpcommHandler=function(e){
109+
letdetailObj=e.detail;
110+
switch(detailObj.type){
111+
case'sendBase':
112+
vp_log('received from inject - ',e.detail.type,e);
113+
// get base url of its extension
114+
vpBase=detailObj.data;
115+
// check if it has vp_wrapper
116+
if(document.getElementById('vp_wrapper')==null){
117+
// initialize vp environment
118+
vp_init();
119+
}else{
120+
// send event to toggle vp
121+
letdetailObj={type:'toggle',data:'hi'};
122+
letevt=newCustomEvent('vpcomm',{bubbles:true,detail:detailObj});
123+
document.dispatchEvent(evt);
124+
}
125+
break;
126+
// CHROME: TODO: 2: use vp frame.toggle for toggle it
127+
// case 'toggle':
128+
// // toggle vp_wrapper
129+
// if (window.vpBase != '' && window.$) {
130+
// vp_toggle();
131+
// } else {
132+
// vp_log('No jquery...');
133+
// // init again
134+
// vp_init();
135+
// }
136+
// break;
137+
default:
138+
break;
139+
}
140+
};
141+
document.removeEventListener('vpcomm',_vpcommHandler);
142+
document.addEventListener('vpcomm',_vpcommHandler);
143+
144+
// End of file

‎colab/manifest.json‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name":"Visual Python for colab",
3+
"description":"Visual Python for colab",
4+
"version":"2.2.12.1",
5+
"manifest_version":3,
6+
"action": {
7+
"default_icon": {
8+
"48":"icon.png"
9+
}
10+
},
11+
"permissions": [
12+
"activeTab",
13+
"scripting"
14+
],
15+
"content_scripts": [
16+
{
17+
"matches": ["https://colab.research.google.com/*"],
18+
"js": ["content.js"],
19+
"all_frames":true
20+
}
21+
],
22+
"web_accessible_resources": [{
23+
"resources": [
24+
"inject.js",
25+
"visualpython/*"
26+
],
27+
"matches": ["<all_urls>"]
28+
}],
29+
"background": {
30+
"service_worker":"background.js"
31+
}
32+
}

‎jupyterlab/.gitignore‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
*.bundle.*
2+
node_modules/
3+
*.egg-info/
4+
.ipynb_checkpoints
5+
*.tsbuildinfo
6+
visualpython/labextension
7+
8+
# Created by https://www.gitignore.io/api/python
9+
# Edit at https://www.gitignore.io/?templates=python
10+
11+
### Python ###
12+
# Byte-compiled / optimized / DLL files
13+
__pycache__/
14+
*.py[cod]
15+
*$py.class
16+
17+
# C extensions
18+
*.so
19+
20+
# Distribution / packaging
21+
.Python
22+
build/
23+
develop-eggs/
24+
dist/
25+
downloads/
26+
eggs/
27+
.eggs/
28+
lib64/
29+
parts/
30+
sdist/
31+
var/
32+
wheels/
33+
pip-wheel-metadata/
34+
share/python-wheels/
35+
.installed.cfg
36+
*.egg
37+
MANIFEST
38+
39+
# PyInstaller
40+
# Usually these files are written by a python script from a template
41+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
42+
*.manifest
43+
*.spec
44+
45+
# Installer logs
46+
pip-log.txt
47+
pip-delete-this-directory.txt
48+
49+
# Unit test / coverage reports
50+
htmlcov/
51+
.tox/
52+
.nox/
53+
.coverage
54+
.coverage.*
55+
.cache
56+
nosetests.xml
57+
coverage.xml
58+
*.cover
59+
.hypothesis/
60+
.pytest_cache/
61+
62+
# Translations
63+
*.mo
64+
*.pot
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Spyder project settings
85+
.spyderproject
86+
.spyproject
87+
88+
# Rope project settings
89+
.ropeproject
90+
91+
# Mr Developer
92+
.mr.developer.cfg
93+
.project
94+
.pydevproject
95+
96+
# mkdocs documentation
97+
/site
98+
99+
# mypy
100+
.mypy_cache/
101+
.dmypy.json
102+
dmypy.json
103+
104+
# Pyre type checker
105+
.pyre/
106+
107+
# End of https://www.gitignore.io/api/python
108+
109+
# OSX files
110+
.DS_Store

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp