Skip to content

Commit

Permalink
Chrome/Firefox fixes;
Browse files Browse the repository at this point in the history
Changelog/history update;
  • Loading branch information
Dither committed Aug 26, 2016
1 parent 01b4917 commit f07ce35
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 81 deletions.
6 changes: 5 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@
width: 60px !important;
bottom: 0 !important;
right: 0 !important;
border 0 !importan;
border 0 !important;
background-image: url(data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA2MCAzMicgZmlsbD0nbGlnaHRncmF5Jz48Y2lyY2xlIHRyYW5zZm9ybT0ndHJhbnNsYXRlKDEwIDApJyBjeD0nMCcgY3k9JzE2JyByPScwJz48YW5pbWF0ZSBhdHRyaWJ1dGVOYW1lPSdyJyB2YWx1ZXM9JzA7IDQ7IDA7IDAnIGR1cj0nMS4ycycgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnIGJlZ2luPScwJyBrZXl0aW1lcz0nMDswLjI7MC43OzEnIGtleVNwbGluZXM9JzAuMiAwLjIgMC40IDAuODswLjIgMC42IDAuNCAwLjg7MC4yIDAuNiAwLjQgMC44JyBjYWxjTW9kZT0nc3BsaW5lJyAvPjwvY2lyY2xlPjxjaXJjbGUgdHJhbnNmb3JtPSd0cmFuc2xhdGUoMzAgMCknIGN4PScwJyBjeT0nMTYnIHI9JzAnPjxhbmltYXRlIGF0dHJpYnV0ZU5hbWU9J3InIHZhbHVlcz0nMDsgNDsgMDsgMCcgZHVyPScxLjJzJyByZXBlYXRDb3VudD0naW5kZWZpbml0ZScgYmVnaW49JzAuMycga2V5dGltZXM9JzA7MC4yOzAuNzsxJyBrZXlTcGxpbmVzPScwLjIgMC4yIDAuNCAwLjg7MC4yIDAuNiAwLjQgMC44OzAuMiAwLjYgMC40IDAuOCcgY2FsY01vZGU9J3NwbGluZScgLz48L2NpcmNsZT48Y2lyY2xlIHRyYW5zZm9ybT0ndHJhbnNsYXRlKDUwIDApJyBjeD0nMCcgY3k9JzE2JyByPScwJz4gPGFuaW1hdGUgYXR0cmlidXRlTmFtZT0ncicgdmFsdWVzPScwOyA0OyAwOyAwJyBkdXI9JzEuMnMnIHJlcGVhdENvdW50PSdpbmRlZmluaXRlJyBiZWdpbj0nMC42JyBrZXl0aW1lcz0nMDswLjI7MC43OzEnIGtleVNwbGluZXM9JzAuMiAwLjIgMC40IDAuODswLjIgMC42IDAuNCAwLjg7MC4yIDAuNiAwLjQgMC44JyBjYWxjTW9kZT0nc3BsaW5lJyAvPjwvY2lyY2xlPjwvc3ZnPg==) !important;
background-position: center !important;
background-repeat: no-repeat !important;
background-size: 100% 100%;

}

#autopatchwork_bar.autopager_loading img {
Expand Down
37 changes: 18 additions & 19 deletions css/manager.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ body,ul,ol,dl,li,dd,dt,p,div,h1,h2,h3,h4,h5,h6 {
}

.name {
padding: 0;
margin: 0;
max-width: 640px;
width: 640px;
}
Expand Down Expand Up @@ -188,7 +190,7 @@ body,ul,ol,dl,li,dd,dt,p,div,h1,h2,h3,h4,h5,h6 {
border: 1px solid #aaa;
cursor: pointer;
width: 100%;
height: 100%;
height: 120%;
margin: 0;
text-overflow: ellipsis;
}
Expand Down Expand Up @@ -350,7 +352,6 @@ th[colspan="6"]+th {
border-right: 2px solid #BBB;
padding: 3px;
overflow: hidden;
text-align: center;
line-height: 38px;
font-size: 14px;
font-weight: bold;
Expand All @@ -359,7 +360,7 @@ th[colspan="6"]+th {
}

#progress {
position: absolute;
text-align: center;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
Expand All @@ -385,50 +386,48 @@ th[colspan="6"]+th {
/* W3C */
overflow: hidden;
z-index: 1002;
position: absolute;
left: 3px;
}

#done {
#progress_percent {
text-align: center;
line-height: 38px;
font-size: 14px;
font-weight: bold;
color: #EEE;
color: #777;
height: 38px;
width: 250px;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
z-index: 1003;
width: 256px;
z-index: 1010;
position: absolute;
left: 3px;
}

td.index {
padding: 0px 3px;
}

span.onoff,
input.onoff {
.onoff {
color: #000;
background-color: #E6E6E6;
background-color: #B6B6B6;
}

span.disable_separator,
input.disable_separator {
.disable_separator {
color: #000;
background-color: #A9D0F5;
}

span.scripts_enable,
input.scripts_enable {
.scripts_enable {
color: #000;
background-color: #F2F5A9;
}

span.force_iframe,
input.force_iframe {
.force_iframe {
color: #000;
background-color: #F5D0A9;
}

span.address_change,
input.address_change {
.address_change {
color: #000;
background-color: #D0F5A9;
}
32 changes: 19 additions & 13 deletions includes/autopatchwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
};

var browser, checksum = new FastCRC32, debug = false, profiler = false, dump_request = false,
var browser_type, checksum = new FastCRC32, debug = false, profiler = false, dump_request = false,
BROWSER_CHROME = 1,
BROWSER_SAFARI = 2,
BROWSER_OPERA = 3;
Expand Down Expand Up @@ -101,9 +101,9 @@
id: -1
};

if ((!!window.chrome && !!window.chrome.webstore) || (typeof InstallTrigger !== 'undefined')) browser = BROWSER_CHROME;
else if (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) browser = BROWSER_SAFARI;
else browser = BROWSER_OPERA;
if ((!!window.chrome && !!window.chrome.runtime) || (typeof InstallTrigger !== 'undefined')) browser_type = BROWSER_CHROME;
else if (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) browser_type = BROWSER_SAFARI;
else browser_type = BROWSER_OPERA;

function APWException(message) {
this.message = message;
Expand Down Expand Up @@ -133,7 +133,7 @@
if (!debug) return;
if (window.console) {
console.log('[AutoPatchWork] ' + Array.prototype.slice.call(arguments));
} else if (browser === BROWSER_OPERA) {
} else if (browser_type === BROWSER_OPERA) {
window.opera.postError('[AutoPatchWork] ' + Array.prototype.slice.call(arguments));
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@
//else return doc.selectSingleNode(path);
}

if (browser === BROWSER_OPERA && !APW.loaded) {
if (!APW.loaded) {
var args = arguments;
document.addEventListener('DOMContentLoaded', function (e) {
APW.loaded = true;
Expand All @@ -258,7 +258,7 @@
}

var sendRequest;
switch (browser) {
switch (browser_type) {
case BROWSER_CHROME:
sendRequest = function (data, callback) {
if (callback) chrome.runtime.sendMessage(data, callback);
Expand Down Expand Up @@ -299,7 +299,7 @@
default:
sendRequest = null;
throw new APWException('Browser not detected!');
} // switch(browser)
} // switch(browser_type)

var matched_siteinfo = [],
rootNode = /BackCompat/.test(document.compatMode) ? document.body : document.documentElement;
Expand Down Expand Up @@ -416,8 +416,9 @@

status.css_patch = siteinfo.cssPatch || null;
status.js_patch = siteinfo.jsPatch || null;
if (status.js_patch)
if (status.js_patch) {
run_script(status.js_patch);
}

status.next_link = siteinfo.nextLink || null;
status.next_link_selector = siteinfo.nextLinkSelector || null;
Expand Down Expand Up @@ -609,12 +610,12 @@
dispatch_event('AutoPatchWork.toggle');
}

//if (browser === BROWSER_OPERA) { // test :before + background-image: url(animated SVG) in CSS for other browsers
if (browser_type === BROWSER_OPERA) { // :before + background-image: url(animated SVG) in CSS for other browsers
var img = document.createElement('img');
img.id = 'autopatchwork_loader';
img.src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 32" width="60" height="32" fill="lightgray"><circle transform="translate(10 0)" cx="0" cy="16" r="0"><animate attributeName="r" values="0; 4; 0; 0" dur="1.2s" repeatCount="indefinite" begin="0" keytimes="0;0.2;0.7;1" keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8" calcMode="spline" /></circle><circle transform="translate(30 0)" cx="0" cy="16" r="0"><animate attributeName="r" values="0; 4; 0; 0" dur="1.2s" repeatCount="indefinite" begin="0.3" keytimes="0;0.2;0.7;1" keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8" calcMode="spline" /></circle><circle transform="translate(50 0)" cx="0" cy="16" r="0"> <animate attributeName="r" values="0; 4; 0; 0" dur="1.2s" repeatCount="indefinite" begin="0.6" keytimes="0;0.2;0.7;1" keySplines="0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8" calcMode="spline" /></circle></svg>';
bar.appendChild(img);
//}
}

document.body.appendChild(bar);
bar.addEventListener('click', function (e) {
Expand Down Expand Up @@ -1022,8 +1023,13 @@
* */
function run_script(text) {
try {
if (text && text.length > 1)
window.eval(text);
if (text && text.length > 1) {
var script = document.createElement('script');
script.textContent = text;
(document.head || document.documentElement).appendChild(script);
script.remove();
//window.eval(text);
}
} catch (bug) {
log(bug.message);
}
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"run_at": "document_start",
"all_frames":true
} ],
"content_security_policy": "script-src 'self' chrome-extension://cfkhagomglmfbenelkfgkglfhbhncilb; object-src 'self' chrome-extension://cfkhagomglmfbenelkfgkglfhbhncilb",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"default_locale": "en_US",
"icons": {
"16": "icons/Icon-16.png",
Expand All @@ -25,7 +25,7 @@
},
"description": "Automatically loads the next page and inserts into current one.",
"name": "AutoPatchWorkMod",
"permissions": [ "unlimited_storage", "tabs", "management", "desktop-notification", "notifications"],
"permissions": [ "unlimited_storage", "tabs", "management", "notifications" ],
"optional_permissions": [ "storage" ],
"options_ui": {
"page": "options.html"
Expand Down
24 changes: 24 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,30 @@ <h4>2013/09/01</h4>
All events targeted to <i>document</i> instead of <i>window</i>.
</li>
</ul>
<h4>2016/07/07</h4>
<ul>
<li>
Firefox 48 and Chrome 49 support.
</li>
<li>
<i>removeElement</i> removes nodes in added pages by selector or XPath rule, <i>jsPatch</i> field allows per site JS patching and <i>cssPatch</i> - CSS patching.
</li>
<li>
Options in SITEINFO manager to disable separators, allow scripts, load pages via IFrames and update URL/title on scroll.
</li>
<li>
Options to make link <i>href</i>s and image <i>src</i>s absolute.
</li>
<li>
SITEINFO database URLs can now be specified.
</li>
<li>
SITEINFO DB can be reloaded to apply changes made in manager without browser restart.
</li>
<li>
Various bugfixes.
</li>
</ul>
</li>
</ul><br />
</section>
Expand Down
37 changes: 18 additions & 19 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ const MICROFORMATs = [/*{
pageElement: '//*[contains(concat(" ",@class," "), " hfeed ") or contains(concat(" ",@class," "), " story ") or contains(concat(" ",@class," "), " instapaper_body ") or contains(concat(" ",@class," "), " xfolkentry ")]'
}*/];

var browser,
var browser_type,
BROWSER_CHROME = 1,
BROWSER_SAFARI = 2,
BROWSER_OPERA = 3;

if((!!window.chrome && !!window.chrome.webstore) || (typeof InstallTrigger !== 'undefined')) browser = BROWSER_CHROME;
else if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) browser = BROWSER_SAFARI;
else browser = BROWSER_OPERA;
if((!!window.chrome && !!window.chrome.runtime) || (typeof InstallTrigger !== 'undefined')) { browser_type = BROWSER_CHROME; if (typeof browser === 'undefined') browser = chrome; }
else if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) browser_type = BROWSER_SAFARI;
else browser_type = BROWSER_OPERA;

/**
* Logging function.
* @param {Array|String} arguments Data to put to debug output.
* */
function log() {
if (!debug) return;
if (browser === BROWSER_OPERA) {
if (browser_type === BROWSER_OPERA) {
window.opera.postError('[AutoPatchWork] ' + Array.prototype.slice.call(arguments));
} else if (window.console) {
window.console.log('[AutoPatchWork] ' + Array.prototype.slice.call(arguments));
Expand Down Expand Up @@ -132,7 +132,7 @@ window.AutoPatchWorkBG = {

//// main //////

if(browser === BROWSER_SAFARI) {
if(browser_type === BROWSER_SAFARI) {
safari.extension.settings.addEventListener('change', function(evt) {
if(evt.key in AutoPatchWorkBG.config) {
AutoPatchWorkBG.config[evt.key] = evt.newValue;
Expand Down Expand Up @@ -338,18 +338,18 @@ window.onload = function() {
group: 'AutoPatchWork',
actions: [{ name: 'AutoPatchWork.toggle' }, { name: 'AutoPatchWork.request' }]
};
//self.chrome && chrome.runtime.sendMessage(CHROME_GESTURES, action);
//self.chrome && chrome.runtime.sendMessage(CHROME_KEYCONFIG, action);
//self.chrome && browser.runtime.sendMessage(CHROME_GESTURES, action);
//self.chrome && browser.runtime.sendMessage(CHROME_KEYCONFIG, action);
};

var toggleCode = '(' + (function() {
var ev = new window.CustomEvent('AutoPatchWork.toggle');
document.dispatchEvent(ev);
}).toString() + ')();';

switch(browser) {
switch(browser_type) {
case BROWSER_CHROME:
chrome.runtime.onMessage.addListener(handleMessage);
browser.runtime.onMessage.addListener(handleMessage);
break;
case BROWSER_SAFARI:
safari.application.addEventListener("message", function(evt) {
Expand Down Expand Up @@ -508,21 +508,20 @@ function handleMessage(request, sender, sendResponse) {
}

function openOrFocusTab(uri) {
switch (browser) {
switch (browser_type) {
case BROWSER_CHROME:
chrome.windows.getAll({ populate: true},
function(windows) {
if(!windows.some(function(w) {
if(w.type === 'normal') {
browser.windows.getAll({ populate: true}, function(windows) {
if (!windows.some(function(w) {
if (w.type === 'normal') {
return w.tabs.some(function(t) {
if(t.url === H + uri) {
chrome.tabs.update(t.id, { 'selected': true });
if (t.url === H + uri) {
browser.tabs.update(t.id, { 'selected': true });
return true;
}
});
}
})) { chrome.tabs.getSelected(null, function(t) {
chrome.tabs.create({ 'url': uri, 'selected': true, index: t.index + 1 });
})) { browser.tabs.query({active: true}, function(t) {
browser.tabs.create({ 'url': uri, index: (t[0] ? t[0].index : 0) + 1 });
});
}
});
Expand Down
Loading

0 comments on commit f07ce35

Please sign in to comment.