Skip to content

Commit

Permalink
多文件修正,新增 contextProxySwitch.uc.xul
Browse files Browse the repository at this point in the history
  • Loading branch information
ywzhaiqi committed Oct 12, 2013
1 parent a4cdee6 commit e03b241
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 0 deletions.
1 change: 1 addition & 0 deletions ExternalVideoPlayer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- 视频链接、视频文字链接、百度云链接、flvcd 网站
- 非分段:[音悦台](http://tv.letv.com/)[乐视网](http://tv.letv.com/)[56网](http://www.56.com)[迅雷看看](http://www.kankan.com/)
- 没法直接播放:[土豆网](http://www.tudou.com/)[奇艺网](http://www.iqiyi.com/)[搜狐视频](http://tv.sohu.com)[PPTV](http://v.pptv.com)
- 百度盘分享的视频可直接观看,体验不错。

### 使用说明

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ userChromeJS for Firefox
### 单文件

- [chromejs.uc.js](chromejs.uc.js),在地址栏运行uc代码,例:打开书签 `chromejs:PlacesCommandHook.showPlacesOrganizer('AllBookmarks');`
- [contextProxySwitch.uc.xul](contextProxySwitch.uc.xul),修正本地文件下 getSelection 是一行的情况。
- [copybookmark.uc.js](copybookmark.uc.js),书签右键复制标题链接(修改版)。
- [downloadPlus.uc.js](downloadPlus.uc.js),多个下载脚本整合版。
- [ExportHTMLFolderMod.uc.xul](ExportHTMLFolderMod.uc.xul),书签右键 `导出到HTML`(修改版)。
Expand Down
20 changes: 20 additions & 0 deletions addmenuPlus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,26 @@ modify the firebug key
// image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABxElEQVQ4jZXQzYsScRzH8d/f16lTFCwRdOoSUYddtlrUaXTVEdR1xqfysLtUrC2EujNjbplPjIGtJIZB6YLMjqu105/w7tQhMB8+99f7C18hVpiiKGiaRjqdJplMsor5B6dSKWzbxnVdVFVdL6CqKuPxmMlkgmmaxOPx9QKapmHbNt1uF0VREEKISCRCOBxmd3d3eSyRSDAcDmk2m4RCIYLBIPl8nsFggCzLiwOyLBOLxej3+7TbbSqVCuVymVqtRqPRQJKk+QE5bSLnPhGNRrEsi06ng2VZtFot6vU61WoVn883Hz/TDLLmhOSJQ/j1N3q9HqVSiUAggCzLSJKE1+udjyXNIKs7VLq/KZ+5hI/HbGd6+P3+5c/yqQYp3eHdmcvL6pT900sK7V94Ds656/+4OOBN6CSLDuXPLocfpqjFC56bE45bP9nKjbjjNf8f2Eno7BUcjI7L4fspe4ULMrrDm8aMzRcjbnuMxde3ckP0zhX7p5fE3tqkTxzy9RmPsiM2dpZgIYS4r32n0L4iY0xIFh2O6jMeZkfceroCFkKIe4qF5+Cco9qMV9UZD1I/uPl4Rfx3G7LFdd9Xrj35wo3t9fAfyK1fDftrXK0AAAAASUVORK5CYII="
});

示例:子菜单中的 测试视频链接 只在 youku 页面显示,其它页面隐藏。

var testMenu = PageMenu({
label: '测试子菜单',
onpopupshowing: function (event){
Array.slice(event.target.children).forEach(function(elem){
if(elem.id == "mtest-video"){
elem.hidden = content.location.host.indexOf("youku") == -1
}
});
}
});
testMenu([
{
id: "mtest-video",
label: "测试视频链接",
hidden: true
}
]);


## 我修改的说明

Expand Down
267 changes: 267 additions & 0 deletions contextProxySwitch.uc.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
<?xml version="1.0"?>

<overlay id="context_ProxySwitch"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--
// ==UserScript==
// @name contextProxySwitch
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description 一発プロキシ設定
// @include main
// @compatibility Firefox 2.0 3.0 3.1
// @author Alice0775
// @Note quickProxyModoki3.0.uc.xulも合わせてどうぞ
// @version 2013/10/12 修正本地文件下 getSelection 是一行的情况
// @version 2013/09/13 00:00 Bug 856437 Remove Components.lookupMethod
// @version 2009/09/06 00:00 httpsも設定するかどうか USE_PROXY_SSL
// ==/UserScript==
// @version 2009/03/16 00:00 初期化時チェック
// @version 2008/12/04 00:00 Cleanup
// @version 2008/11/03 00:00 PACファイル使用中の表示
// @version 2007/06/17 00:00 http://www.cybersyndrome.net/ のproxyを選択して一括登録
// @version 2007/06/15
-->
<script type="application/x-javascript" xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
var ucjsProxy ={
// --- config ---
USE_PROXY_SSL:false, //httpsも設定 true:する, [false]しない
// --- config ---
_Prefs: Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch),
_exp:/([a-z0-9_\-]+(\.[a-z0-9_\-]+)+):(\d+)/i,
_Switch: function _Switch() {
var first = true;
var text = this._getselection();
var texts = text.split("\n");
for (var i = 0; i < texts.length; i++){
var xx = texts[i].match(this._exp);
var proxyhttp = RegExp.$1;
var proxyhttp_port = parseInt(RegExp.$3, 10);
if( !xx || text =='' || proxyhttp_port <= 0 || proxyhttp_port > 65535 || proxyhttp == '') {
//串じゃない
this.deselectProxy();
} else {
//たぶん串なので串をセットする
this.addProxy(proxyhttp + ":" + proxyhttp_port);
if (first){
this.selectProxy(proxyhttp + ":" + proxyhttp_port);
first = false;
}
}
}
},
addProxy: function(proxy){
try{
var proxys = this._Prefs.getCharPref("userChrome_js.network.proxys");
}catch(e){
var proxys = "";
}
proxys = proxys.replace(proxy, "");
proxys = (proxys + "," + proxy).replace(/,,/, ',').replace(/^,/, '').replace(/,$/, '');
this._Prefs.setCharPref("userChrome_js.network.proxys", proxys);
},
delProxy: function(proxy){
try{
var proxys = this._Prefs.getCharPref("userChrome_js.network.proxys");
proxys = proxys.replace(proxy, "").replace(/,,/, ',').replace(/^,/, '').replace(/,$/, '');
this._Prefs.setCharPref("userChrome_js.network.proxys", proxys);
}catch(e){}
},
deselectProxy: function(){
this._Prefs.setIntPref("network.proxy.type", 0);
document.getElementById('nonProxy').setAttribute('checked', true);
},
PACProxy: function(){
this._Prefs.setIntPref("network.proxy.type", 2);
document.getElementById('PACProxy').setAttribute('checked', true);
},
allDelete: function(){
this._Prefs.setIntPref("network.proxy.type", 0);
this._Prefs.setCharPref("userChrome_js.network.proxys", '');
},
selectProxy: function(proxy){
var xx = proxy.match(this._exp);
var proxyhttp = RegExp.$1;
var proxyhttp_port = parseInt(RegExp.$3, 10);
this._Prefs.setCharPref("network.proxy.http", proxyhttp);
this._Prefs.setIntPref("network.proxy.http_port", proxyhttp_port);
this._Prefs.setCharPref("network.proxy.ftp", proxyhttp);
this._Prefs.setIntPref("network.proxy.ftp_port", proxyhttp_port);
if (this.USE_PROXY_SSL) {
this._Prefs.setCharPref("network.proxy.ssl", proxyhttp);
this._Prefs.setIntPref("network.proxy.ssl_port", proxyhttp_port);
}
this._Prefs.setIntPref("network.proxy.type", 1);
},
_getFocusedWindow: function(){
var focusedWindow = document.commandDispatcher.focusedWindow;
if (!focusedWindow || focusedWindow == window)
return window._content;
else
return focusedWindow;
},
_getselection: function() {
var targetWindow = this._getFocusedWindow();
// 修正本地文件下是一行的情况
var sel;
if(targetWindow.document.doctype){
sel = targetWindow.getSelection();
} else {
sel = targetWindow.getSelection().anchorNode.data;
}
// for textfields
if (sel && !sel.toString()) {
var node = document.commandDispatcher.focusedElement;
if (node &&
(node.type == "text" || node.type == "textarea") &&
'selectionStart' in node &&
node.selectionStart != node.selectionEnd) {
var offsetStart = Math.min(node.selectionStart, node.selectionEnd);
var offsetEnd = Math.max(node.selectionStart, node.selectionEnd);
return node.value.substr(offsetStart, offsetEnd-offsetStart);
}
}
return sel ? sel.toString() : "";
},
addMenuItem: function(proxy){
var menuitem = document.createElement('menuitem');
var menupopup = document.getElementById('contextProxySwitchMenupopup');
menupopup.appendChild(menuitem);
menuitem.setAttribute('label', proxy);
menuitem.setAttribute('type', 'radio');
menuitem.setAttribute('checked', false);
menuitem.setAttribute('name', 'contextPproxy');
menuitem.setAttribute('tooltiptext', '鼠标中键删除');
menuitem.setAttribute('oncommand', 'ucjsProxy.selectProxy(this.getAttribute("label"));');
menuitem.setAttribute('onclick', 'if(event.button==1){ucjsProxy.deleteMenuItem(event);}');
return menuitem;
},
deleteMenuItem: function(event){
var target = event.target;
if (target.getAttribute('checked') == 'true'){
this.deselectProxy();
}
this.delProxy(target.getAttribute('label'));
target.parentNode.removeChild(target)
},
popupOnshowing: function(menupopup){
for (var j = 0; j < menupopup.childNodes.length; j++){
if (menupopup.childNodes[j].getAttribute('id') == 'contextProxySwitchMenuSeparator'){
break;
}
}
for (var i = menupopup.childNodes.length - 1; i > j; i--){
menupopup.removeChild(menupopup.lastChild);
}
try {
var proxys = this._Prefs.getCharPref("userChrome_js.network.proxys").split(",");
} catch(e) {
var proxys = [];
}
var enable = this._Prefs.getIntPref("network.proxy.type");
var proxyhttp = this._Prefs.getCharPref("network.proxy.http");
var proxyhttp_port = this._Prefs.getIntPref("network.proxy.http_port");
if (this._getselection() == '')
document.getElementById('contextProxySwitchSelect').setAttribute('disabled', true);
else
document.getElementById('contextProxySwitchSelect').removeAttribute('disabled');
var menuitem;
var flg = false;
for (var i=0; i<proxys.length; i++){
if (!proxys[i])
continue;
menuitem = this.addMenuItem(proxys[i]);
if(enable == 1 && proxys[i] == (proxyhttp + ":" + proxyhttp_port)) {
flg = true;
menuitem.setAttribute('checked', true);
}
}
if (!flg && enable == 1) {
this.addProxy(proxyhttp + ":" + proxyhttp_port);
/*
enable = 0;
this._Prefs.setIntPref("network.proxy.type", enable);
*/
}
document.getElementById('nonProxy').setAttribute('checked', (enable == 0));
document.getElementById('PacProxy').setAttribute('checked', (enable == 2));
},
init: function(){
try {
var proxys = this._Prefs.getCharPref("userChrome_js.network.proxys").split(",");
} catch(e) {
var proxys = [];
}
var enable = this._Prefs.getIntPref("network.proxy.type");
var proxyhttp = this._Prefs.getCharPref("network.proxy.http");
var proxyhttp_port = this._Prefs.getIntPref("network.proxy.http_port");
var flg = false;
for (var i=0; i<proxys.length; i++){
if (!proxys[i])
continue;
if(enable == 1 && proxys[i] == (proxyhttp + ":" + proxyhttp_port)) {
flg = true;
}
}
if (!flg && enable == 1) {
this.addProxy(proxyhttp + ":" + proxyhttp_port);
/*
enable = 0;
this._Prefs.setIntPref("network.proxy.type", enable);
*/
}
}
}
ucjsProxy.init();
]]></script>

// This is for the right click menu.
<popup id="contentAreaContextMenu">
<menu label="代理设置">
<menupopup id="contextProxySwitchMenupopup"
onpopupshowing="ucjsProxy.popupOnshowing(this);">
<menuitem id="contextProxySwitchSelect"
label="添加至代理"
oncommand="ucjsProxy._Switch();"/>
<menuitem label="移除全部代理"
oncommand="ucjsProxy.allDelete();"/>
<menuseparator/>
<menuitem id="nonProxy"
type="radio"
name="contextPproxy"
checked="true"
label="禁用代理"
oncommand="ucjsProxy.deselectProxy();"/>
<menuitem id="PacProxy"
type="radio"
name="contextPproxy"
checked="true"
label="使用PAC代理"
oncommand="ucjsProxy.PACProxy();"/>
<menuseparator id="contextProxySwitchMenuSeparator"/>
</menupopup>
</menu>
</popup>
</overlay>

0 comments on commit e03b241

Please sign in to comment.