diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 230df357..b155c03e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,8 @@ -2024.1.1 (in-dev) +2024.1.1 + +New features: + + * Support for ~25 new websites (using ~15 new rules) Improvements: diff --git a/build/ImageMaxURL_crx3.crx b/build/ImageMaxURL_crx3.crx index ef73d9e0..c3537798 100644 Binary files a/build/ImageMaxURL_crx3.crx and b/build/ImageMaxURL_crx3.crx differ diff --git a/build/ImageMaxURL_unsigned.xpi b/build/ImageMaxURL_unsigned.xpi index 9ed0f62d..96d8cd52 100644 Binary files a/build/ImageMaxURL_unsigned.xpi and b/build/ImageMaxURL_unsigned.xpi differ diff --git a/build/userscript_extr.user.js b/build/userscript_extr.user.js index 3d39b4b0..690f3819 100644 --- a/build/userscript_extr.user.js +++ b/build/userscript_extr.user.js @@ -64,7 +64,7 @@ // @description:zh-TW 為9100多個網站查找更大或原始圖像 // @description:zh-HK 為9100多個網站查找更大或原始圖像 // @namespace http://tampermonkey.net/ -// @version 2024.1.0 +// @version 2024.1.1 // @author qsniyg // @homepageURL https://qsniyg.github.io/maxurl/options.html // @supportURL https://github.com/qsniyg/maxurl/issues @@ -100,7 +100,7 @@ // Note that jsdelivr.net might not always be reliable, but (AFAIK) this is the only reasonable option from what greasyfork allows. // I'd recommend using the Github version of the script if you encounter any issues (linked in the 'Project links' section below). // -// @require https://cdn.jsdelivr.net/gh/qsniyg/maxurl@884bd053df1d72fff56ef409879657e8aa8876d9/build/rules.js +// @require https://cdn.jsdelivr.net/gh/qsniyg/maxurl@72662d9ece42752843b5392c784f04d2147e5b21/build/rules.js // ==/UserScript== // If you see "A userscript wants to access a cross-origin resource.", it's used for: // * Detecting whether or not the destination URL exists before redirecting @@ -17746,13 +17746,13 @@ var $$IMU_EXPORT$$; data: bigimage_obj, message: "Unable to get bigimage function" }; - } else if (bigimage_obj.nonce !== "lg6h2o1l2f5md2l1") { + } else if (bigimage_obj.nonce !== "b7h935abmpb428pa") { // This could happen if for some reason the userscript manager updates the userscript, // but not the required libraries. require_rules_failed = { type: "bad_nonce", data: bigimage_obj.nonce, - message: "Bad nonce, expected: " + "lg6h2o1l2f5md2l1" + message: "Bad nonce, expected: " + "b7h935abmpb428pa" }; } else { bigimage = bigimage_obj.bigimage; @@ -17866,6 +17866,12 @@ var $$IMU_EXPORT$$; } } } + if (tree[i].attrs) { + for (var attr in tree[i].attrs) { + if (current.getAttribute(attr) !== tree[i].attrs[attr]) + return "default"; + } + } current = current.parentElement; } var items = current.querySelectorAll(selector); @@ -18748,6 +18754,24 @@ var $$IMU_EXPORT$$; } }; } + if (host_domain_nowww === "gofile.io") { + return { + element_ok: function(el) { + // FIXME: this disregards the mouseover_links setting + if (el.tagName.toUpperCase() === "A" && el.classList.contains("contentLink")) + return true; + }, + gallery: function(el, nextprev) { + if (el.tagName.toUpperCase() === "A" && el.classList.contains("contentLink")) { + return get_nextprev_from_tree(el, nextprev, [ + { tagName: "A", attrs: { class: el.getAttribute("class") } }, + { tagName: "DIV" }, + { tagName: "DIV", classList: ["contentId"] } + ], ".contentId > div > a[class=\"" + el.getAttribute("class") + "\"]"); + } + } + }; + } return null; }; var _get_album_info_gallery = function(album_info, el, nextprev) { @@ -19449,7 +19473,8 @@ var $$IMU_EXPORT$$; fine_urls: [], tried_urls: [], oldobj: [], - tried_imus: [] + tried_imus: [], + redirect_map: {} // FIXME: is this needed? }; } var fine_urls = state.fine_urls; @@ -19471,22 +19496,22 @@ var $$IMU_EXPORT$$; console_log("bigimage_recursive_loop's cb: oldobj:", deepcopy(oldobj)); } obj = obj_merge(obj, oldobj); - var images = obj_to_simplelist(obj); + var image_urls = obj_to_simplelist(obj); for (var i = 0; i < obj.length; i++) { // TODO: also remove bad_if if (obj[i].bad) { var bad_url = obj[i].url; obj.splice(i, 1); - images.splice(i, 1); + image_urls.splice(i, 1); i--; for (var j = 0; j < tried_urls.length; j++) { if (tried_urls[j].newurl === bad_url) { var orig_url = tried_urls[j].newobj.url; - var index = array_indexof(images, orig_url); + var index = array_indexof(image_urls, orig_url); tried_urls[j].redirects_to_bad = true; if (index >= 0) { obj.splice(index, 1); - images.splice(index, 1); + image_urls.splice(index, 1); if (index < i) i -= 2; else if (index === i) @@ -19496,15 +19521,28 @@ var $$IMU_EXPORT$$; } } } + // FIXME: is this needed? + if (false && obj[i].url in state.redirect_map) { + var to = state.redirect_map[obj[i].url]; + var j = void 0; + for (j = i + 1; j < obj.length; j++) { + if (obj[j].url === to) { + obj.splice(i, j - i); + image_urls.splice(i, j - i); + break; + } + } + i -= 1; + } } if (_nir_debug_) { console_log("bigimage_recursive_loop's cb: obj after:", deepcopy(obj)); - console_log("bigimage_recursive_loop's cb: images after:", deepcopy(images)); + console_log("bigimage_recursive_loop's cb: image_urls after:", deepcopy(image_urls)); console_log("bigimage_recursive_loop's cb: fine_urls:", deepcopy(fine_urls)); console_log("bigimage_recursive_loop's cb: tried_urls:", deepcopy(tried_urls)); } for (var i = 0; i < fine_urls.length; i++) { - var index = array_indexof(images, fine_urls[i].url); + var index = array_indexof(image_urls, fine_urls[i].url); if (index >= 0) { obj = [obj[index]]; if (_nir_debug_) { @@ -19520,7 +19558,7 @@ var $$IMU_EXPORT$$; try_any = true; continue; } - var index = array_indexof(images, tried_urls[i].newurl); + var index = array_indexof(image_urls, tried_urls[i].newurl); if (index >= 0) { obj = [obj[index]]; if (_nir_debug_) { @@ -19559,8 +19597,9 @@ var $$IMU_EXPORT$$; newobj: deepcopy(newobj), redirects_to_bad: false }); - //if (array_indexof(images, newurl) < 0 && newurl !== url || true) { - var newurl_index = array_indexof(images, newurl); + state.redirect_map[url] = newurl; + //if (array_indexof(image_urls, newurl) < 0 && newurl !== url || true) { + var newurl_index = array_indexof(image_urls, newurl); if (newurl_index < 0 && already_tried_url) { if (_nir_debug_) { console_log("bigimage_recursive_loop (query): already tried url", deepcopy(state)); @@ -19568,9 +19607,10 @@ var $$IMU_EXPORT$$; return options.cb(null, data); } if (newurl_index < 0 || !obj[newurl_index].norecurse) { + state.oldobj = obj; bigimage_recursive_loop(newurl, options, query, state); } else { - //obj = obj.slice(array_indexof(images, newurl)); + //obj = obj.slice(array_indexof(image_urls, newurl)); obj = [obj[newurl_index]]; if (_nir_debug_) { console_log("bigimage_recursive_loop (query): returning", deepcopy(obj), data); @@ -19584,7 +19624,7 @@ var $$IMU_EXPORT$$; } } if (_nir_debug_) { - console_log("bigimage_recursive_loop", url, deepcopy(options), query, deepcopy(fine_urls), deepcopy(tried_urls), deepcopy(oldobj)); + console_log("bigimage_recursive_loop", url, deepcopy(options), query, deepcopy(state)); } return bigimage_recursive(url, newoptions); }; @@ -27540,7 +27580,23 @@ var $$IMU_EXPORT$$; return result; } function get_bounding_client_rect(el, mapcache) { + var need_qsa_patch = false; + // ublock origin patches getBoundingClientRect under youtube, calling document.querySelectorAll every time, which is very slow + if (/youtube\.com$/.test(window.location.host)) + need_qsa_patch = true; + var old_selectorall = null; + if (need_qsa_patch) { + old_selectorall = document.querySelectorAll; + try { + document.querySelectorAll = function() { return []; }; + } catch (e) { } + } var obj = get_bounding_client_rect_inner(el, mapcache, true); + if (need_qsa_patch) { + try { + document.querySelectorAll = old_selectorall; + } catch (e) { } + } return obj.rect || obj.orig_rect; } function get_popup_client_rect() { @@ -27945,10 +28001,10 @@ var $$IMU_EXPORT$$; } } if (el_tagname === "A" || (settings.mouseover_allow_iframe_el && el_tagname === "IFRAME")) { - var src_1 = get_img_src(el); - links[src_1] = { + var src_2 = get_img_src(el); + links[src_2] = { count: 1, - src: src_1, + src: src_2, el: el, id: id++ }; diff --git a/build/userscript_extr_min.user.js b/build/userscript_extr_min.user.js index 603ef2cb..9431dcfc 100644 --- a/build/userscript_extr_min.user.js +++ b/build/userscript_extr_min.user.js @@ -62,7 +62,7 @@ // @description:zh-TW 為9100多個網站查找更大或原始圖像 // @description:zh-HK 為9100多個網站查找更大或原始圖像 // @namespace http://tampermonkey.net/ -// @version 2024.1.0 +// @version 2024.1.1 // @author qsniyg // @homepageURL https://qsniyg.github.io/maxurl/options.html // @supportURL https://github.com/qsniyg/maxurl/issues @@ -98,7 +98,7 @@ // Note that jsdelivr.net might not always be reliable, but (AFAIK) this is the only reasonable option from what greasyfork allows. // I'd recommend using the Github version of the script if you encounter any issues (linked in the 'Project links' section below). // -// @require https://cdn.jsdelivr.net/gh/qsniyg/maxurl@884bd053df1d72fff56ef409879657e8aa8876d9/build/rules.js +// @require https://cdn.jsdelivr.net/gh/qsniyg/maxurl@72662d9ece42752843b5392c784f04d2147e5b21/build/rules.js // ==/UserScript== // Due to OpenUserJS's 1MB limit, the source code had to be minified. @@ -107,4 +107,4 @@ // You can view the original source code here: https://github.com/qsniyg/maxurl/blob/master/userscript.user.js // Please let me know if you have any questions or concerns regarding the script. -var $$IMU_EXPORT$$;!function(){function zi(){}function Ni(){var e=d();return e.self||e}function Si(e){if(s||!bi.imu_enabled)return!0;if(e&&Zr)try{chrome.runtime.getURL("manifest.json")}catch(e){return Ui(!0),!0}return!1}var t,Yr=!1,Zr=(Yr&&(Yr={no_request:!1,no_recurse:!1,no_redirect:!0,map:!1,cache:!1,bigimage_recursive:!0,input:!1,check_image_get:!1,find_source:!1},console.log("Loaded")),!1),o=!1,r=!1,Kr=null,i=function(e){},s=!1,P=!1,qi=!1,n=!1,Jr=null,b="https://qsniyg.github.io/maxurl/options.html",a=b,l="https://addons.mozilla.org/en-US/firefox/addon/image-max-url/",u="https://raw.githubusercontent.com/qsniyg/maxurl/master/userscript_smaller.user.js",Ti="https://github.com/qsniyg/maxurl/issues",H=null,Ii=!1,Ai=!0,c=!1,d=function(){return"undefined"!=typeof unsafeWindow?unsafeWindow||this.window||window:this.window||window},Ei=[],Ui=function(e){var t=s;(s=e)&&!t&&mi(Ei,function(e){e()})};try{Jr=window.location.href,E=Jr.replace(/^[a-z]+:\/\/web\.archive\.org\/+web\/+[0-9]+\/+(https?:\/\/)/,"$1"),/^https?:\/\/qsniyg\.github\.io\/+maxurl\/+options\.html/.test(E)||/^file:\/\/.*\/maxurl\/site\/options\.html/.test(Jr)?n=qi=!0:(/^https?:\/\/qsniyg\.github\.io\/+maxurl\/+/.test(E)||/^file:\/\/.*\/maxurl\/site\/(?:index|about|options)\.html/.test(Jr))&&(n=!0)}catch(e){}!function(){if("object"==typeof chrome&&chrome&&"object"==typeof chrome.runtime)try{var e=chrome.runtime.getManifest();if(!(Zr="Image Max URL"===e.name))return;i=function(e){try{var t=chrome.runtime.lastError;t&&console.error(t.message,e)}catch(e){console.error(e)}},o=/^([-a-z]+)extension:\/\/[^/]+\/+_generated_background_page\.html/.test(Jr),t=chrome.runtime.getURL("extension/options.html"),P=Jr.replace(/[?#].*$/,"")===t,qi=qi||P,a=t,0<=navigator.userAgent.indexOf("Firefox")&&(r=!0),H=e.version,Kr=function(e,t){return e=_i(e,{json:!0}),t=t||zi,o?userscript_extension_message_handler(e,t):t&&t!==zi?chrome.runtime.sendMessage(null,e,null,function(){return i(e),t.apply(this,arguments)}):chrome.runtime.sendMessage(null,e)},o||setTimeout(function(){chrome.runtime.connect().onDisconnect.addListener(function(e){console.error(e),i(),Ui(!0)})},10),i()}catch(e){Zr&&(console.error(e),i())}}();var p=!1,m=!1;if("undefined"!=typeof module&&module.exports&&"undefined"==typeof window&&"undefined"==typeof document){p=!0;try{require.main===module&&(m=!0)}catch(e){}}var h=!1,_e=("undefined"!=typeof imu_variable&&"undefined"==typeof GM_xmlhttpRequest&&"undefined"==typeof GM&&(h=!0),!1),Qr=(p||h||Zr||(_e=!0),function(){try{return window.self!==window.top}catch(e){return!0}}()),f=!1,v=(Zr||_e)&&!o,y="unknown",_="";if(_e){var w=void 0;"function"==typeof GM_info?w=GM_info():"object"==typeof GM_info&&(w=GM_info),"object"==typeof w?(w.scriptHandler&&(y=w.scriptHandler),w.version&&(_=w.version)):"function"==typeof GM_fetch&&null===w&&(w={scriptHandler:y="FireMonkey"});try{H=w.script.version}catch(e){H=null}}function k(e){return U(e,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")}var ei,x,C,ti,oi,ri,z,N,Ri,ii,Di,S,q,T,I,ni,A=console.log,ai=function(){for(var e=0;e>>(a-=8)&255)||o>4&15)+(ae>>i%8&15))%e+se.op_start;0<=oi(t,n)?r++:o.push([n,(255&ae)+i,((15&ae)+i)%5])}var a=gi.create_vm_ops(o);try{var s=parseFloat(se.run(a,ae+""));isNaN(s)||(ae+=s)}catch(e){}}return(ae=(ae+Date.now())%1e8)/1e8},di=function(){for(var e=-1/0,t=0;tblob:",_i(e),i),p(i)}var o,r,i=e;e.response?(o=null,Zr&&"_responseEncoded"in e&&e._responseEncoded.type?o=e._responseEncoded.type:e.responseHeaders&&(r=jn(Ln(e.responseHeaders)))["content-type"]&&(o=r["content-type"]),r=void(i=mn(e)),Ri(e.response,function(e){i.response=e,t()},r=o?{type:o}:r)):t()},r.responseType="arraybuffer",r.imu_responseType="blob"),Yr&&ai("do_request (modified data):",_i(r)),h(r)}:v&&console.warn("Unable to initialize do_request, most functions will likely fail"),function(e){return bi.filename_replace_special_underscores?e.replace(/["<>/:?\\*|\^]/g,"_"):e}),Ie=function(e,t,o){Yr&&ai("do_browser_download",e,t,o);var r=ni("a");r.href=e.url,t&&0=o)return c(e);"content-type"in t&&(g=t["content-type"]),d&&(p.total_size=o);for(var r=[],i=e.response.byteLength;;i+=f){var n=[i],a=!0;if(f`":{ko:"