This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Now you can click the button in the popup page! I don't really know what caused my problem before.... Other modification: * change name from "法令易讀器" to "法規亦毒氣"; old english name "zhLawEasyRead" is gone from `manifest.json`, but I haven't decided yet whether to retain it in cases that only english names are permittable. * debugged #8 by modifying `ly.lci.js`; I misused `document.location.pathname` to detect sub-string in search part.
- Loading branch information
Showing
7 changed files
with
128 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,45 @@ | ||
if(typeof LER == "object") (function(){ | ||
if(LER.autoParse instanceof Element) { | ||
LER.parse(LER.autoParse); | ||
LER.debugTime("parsed all"); | ||
} | ||
|
||
/** 加上懸浮按鈕 | ||
* 加在沒有frame,或是最左下角的frame裡頭(不理iFrame) | ||
* 以下程式碼先判斷「『這個』是不是top左下角的那個frame」 | ||
*/ | ||
var target; | ||
if(top.document && top.document.domain == document.domain) { | ||
var fs; | ||
if(fs = top.document.getElementsByTagName("FRAMESET")[0]) { | ||
var rows = fs.rows ? fs.rows.split(",").length : 1; | ||
var cols = fs.cols ? fs.cols.split(",").length : 1; | ||
target = fs.getElementsByTagName("FRAME")[(rows-1)*cols].contentWindow; | ||
} | ||
} | ||
if(document.location.protocol != "file:" | ||
&& ( | ||
(window == top && !document.getElementsByTagName("FRAMESET").length) | ||
|| window == target | ||
) | ||
) { | ||
console.log("fixed label"); | ||
var fixed = document.createElement("DIV"); | ||
var defaultText = "法令\n亦毒氣"; | ||
fixed.appendChild(document.createTextNode(defaultText)); | ||
fixed.setAttribute("title", "按下以再次分析/處理網頁內容\n(我知道這按鈕很像廣告,\n有請高手教我如何從 contextMenu 或 browserAction 存取網頁內容…)"); | ||
fixed.onclick = function(){LER.parse(document.body); LER.debugTime("parse again");}; | ||
fixed.onmouseover = function(){this.innerText = "按下\n以轉換";}; | ||
fixed.onmouseout = function(){this.innerText = defaultText;}; | ||
fixed.className = "LER-fixed"; | ||
document.body.appendChild(fixed); | ||
} | ||
if(typeof LER == "object") (function(){ | ||
if(LER.autoParse instanceof Element) { | ||
LER.parse(LER.autoParse); | ||
LER.debugTime("parsed all"); | ||
} | ||
|
||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
if (request.greeting == "hello") { | ||
LER.parse(document.body); | ||
} | ||
} | ||
); | ||
|
||
/** 加上懸浮按鈕--之前觸發不成功時用的 | ||
* 加在沒有frame,或是最左下角的frame裡頭(不理iFrame) | ||
* 以下程式碼先判斷「『這個』是不是top左下角的那個frame」 | ||
*/ | ||
/*var target; | ||
if(top.document && top.document.domain == document.domain) { | ||
var fs; | ||
if(fs = top.document.getElementsByTagName("FRAMESET")[0]) { | ||
var rows = fs.rows ? fs.rows.split(",").length : 1; | ||
var cols = fs.cols ? fs.cols.split(",").length : 1; | ||
target = fs.getElementsByTagName("FRAME")[(rows-1)*cols].contentWindow; | ||
} | ||
} | ||
if(document.location.protocol != "file:" | ||
&& ( | ||
(window == top && !document.getElementsByTagName("FRAMESET").length) | ||
|| window == target | ||
) | ||
) { | ||
//console.log("fixed label"); | ||
var fixed = document.createElement("DIV"); | ||
var defaultText = "法令\n亦毒氣"; | ||
fixed.appendChild(document.createTextNode(defaultText)); | ||
fixed.setAttribute("title", "按下以再次分析/處理網頁內容\n(我知道這按鈕很像廣告,\n有請高手教我如何從 contextMenu 或 browserAction 存取網頁內容…)"); | ||
fixed.onclick = function(){LER.parse(document.body); LER.debugTime("parse again");}; | ||
fixed.onmouseover = function(){this.innerText = "按下\n以轉換";}; | ||
fixed.onmouseout = function(){this.innerText = defaultText;}; | ||
fixed.className = "LER-fixed"; | ||
document.body.appendChild(fixed); | ||
}*/ | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
{ | ||
"name": "zhLawEasyRead", | ||
"description": "Replace chinese words of sequence number of law articles into arabic or roman numerals.", | ||
"version": "0.3.9.11", | ||
"manifest_version": 2, | ||
"icons" : {"128": "icon.png"}, | ||
"options_page": "options.html", | ||
"browser_action": { | ||
"default_icon": "icon.png", | ||
"default_title": "法令易讀器", | ||
"default_popup": "popup.html" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["<all_urls>"], | ||
"exclude_matches": [ | ||
"http://law.moj.gov.tw/Eng/*", | ||
"*://drive.google.com/keep*", | ||
"*://docs.google.com/*" | ||
], | ||
"css": ["main.css"], | ||
"js": [ | ||
"parseInt.js", | ||
"pcodes.js", | ||
"aliases.js", | ||
"lyIDs.js", | ||
"courts.js", | ||
"LER.js" | ||
], | ||
"all_frames": true | ||
}, | ||
{ | ||
"matches": ["http://www.judicial.gov.tw/constitutionalcourt/p03_01.asp*"], | ||
"css": ["constitutionalcourt.css"], | ||
"js": ["constitutionalcourt.js"] | ||
}, | ||
{ | ||
"matches": ["http://jirs.judicial.gov.tw/*"], | ||
"css": ["jirs.css"], | ||
"js": ["jirs.js"] | ||
}, | ||
{ | ||
"matches": ["http://lis.ly.gov.tw/*"], | ||
"css": ["ly.css"], | ||
"js": ["ly.js"] | ||
}, | ||
{ | ||
"matches": ["http://lci.ly.gov.tw/*"], | ||
"js": ["ly.lci.js"] | ||
}, | ||
{ | ||
"matches": ["http://law.moj.gov.tw/*"], | ||
"exclude_matches": ["http://law.moj.gov.tw/Eng/*"], | ||
"js": ["moj.js"] | ||
}, | ||
{ | ||
"matches": ["<all_urls>"], | ||
"js": ["auto.js"], | ||
"run_at": "document_idle", | ||
"all_frames": true | ||
} | ||
] | ||
} | ||
{ | ||
"manifest_version": 2, | ||
"name": "法規亦毒氣", | ||
"description": "將網頁中的法規與條號都轉變成連結,讓您快速查閱指定條文。", | ||
"version": "0.3.10", | ||
"icons" : {"128": "icon.png"}, | ||
"options_page": "options.html", | ||
"browser_action": { | ||
"default_icon": "icon.png", | ||
"default_title": "法規亦毒氣", | ||
"default_popup": "popup.html" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["<all_urls>"], | ||
"exclude_matches": [ | ||
"http://law.moj.gov.tw/Eng/*", | ||
"*://drive.google.com/keep*", | ||
"*://docs.google.com/*" | ||
], | ||
"css": ["main.css"], | ||
"js": [ | ||
"parseInt.js", | ||
"pcodes.js", | ||
"aliases.js", | ||
"lyIDs.js", | ||
"courts.js", | ||
"LER.js" | ||
], | ||
"all_frames": true | ||
}, | ||
{ | ||
"matches": ["http://www.judicial.gov.tw/constitutionalcourt/p03_01.asp*"], | ||
"css": ["constitutionalcourt.css"], | ||
"js": ["constitutionalcourt.js"] | ||
}, | ||
{ | ||
"matches": ["http://jirs.judicial.gov.tw/*"], | ||
"css": ["jirs.css"], | ||
"js": ["jirs.js"] | ||
}, | ||
{ | ||
"matches": ["http://lis.ly.gov.tw/*"], | ||
"css": ["ly.css"], | ||
"js": ["ly.js"] | ||
}, | ||
{ | ||
"matches": ["http://lci.ly.gov.tw/*"], | ||
"js": ["ly.lci.js"] | ||
}, | ||
{ | ||
"matches": ["http://law.moj.gov.tw/*"], | ||
"exclude_matches": ["http://law.moj.gov.tw/Eng/*"], | ||
"js": ["moj.js"] | ||
}, | ||
{ | ||
"matches": ["<all_urls>"], | ||
"js": ["auto.js"], | ||
"run_at": "document_idle", | ||
"all_frames": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
console.log("DOMContentLoaded"); | ||
document.getElementsByTagName("BUTTON")[0].onclick = function() { | ||
chrome.tabs.getSelected(null, function(tab) { | ||
console.log("button clicked on tab " + tab.id); | ||
chrome.tabs.sendMessage(tab.id, {greeting: "hello"}, function(response) { | ||
console.log(response); | ||
}); | ||
}); | ||
}; | ||
}); |